react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
741 stars 285 forks source link

Showing there is no completion handler with notification id even if finish is called #216

Open vishgoel007 opened 3 years ago

vishgoel007 commented 3 years ago
import PushNotificationIOS from "@react-native-community/push-notification-ios";

componentDidMount() {
    PushNotificationIOS.addEventListener("notification", this.onRemoteNotification);
}

  onRemoteNotification = (notification) => {

    let data = notification.getData();

    if (data) {
     // ...
    }
    notification.finish(PushNotificationIOS.FetchResult.NoData);
  };

I'm using remote notification listener like this and onRemoteNotification called when a remote notification come but when i trigger multiple notifications manually onRemoteNotification stopped calling for sometime and then start calling after like 10-15 minutes. In xcode i'm getting this There is no completion handler with notification id: 4A0009xxxx-xxx but i have called finish function at the end of onRemoteNotification, so why i'm getting this no completion handler warning ? and is it because of this no completion handler warning onRemoteNotification stopped calling for sometime ?

joebernard commented 3 years ago

I noticed that completionHandler() was removed from the instructions in the readme recently: https://github.com/react-native-push-notification-ios/push-notification-ios/pull/207/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L119

Are you calling completionHandler() there? Perhaps this is related to your issue.

vishgoel007 commented 3 years ago

@joebernard Still showing same error even if I add completionHandler() in code.

joebernard commented 3 years ago

Could it be that APNS is throttling your notifications when you start sending multiple manually? Maybe Apple is delaying them and they are reaching your device late.

Do you see the completion handler error for all notifications or just when they are delayed?

vishgoel007 commented 3 years ago

@joebernard Notifications are not getting delayed, they are reaching on time but the listener handler onRemoteNotification stop getting called after sometime and then start behaving normally after approx 15 minutes. And it is showing completion handler error for all notifications.

jrobichaud commented 3 years ago

I confirm fetchCompletionHandleris not called:

[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:^(UIBackgroundFetchResult result){
    // Never called
  }];

along with this code:

PushNotificationIOS.addEventListener('notification', (notification) => {
  notification.finish(PushNotificationIOS.FetchResult.NoData);
});