ios icon indicating copy to clipboard operation
ios copied to clipboard

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

Open vishgoel007 opened this issue 4 years ago • 5 comments

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 ?

vishgoel007 avatar Oct 27 '20 05:10 vishgoel007

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.

joebernard avatar Oct 27 '20 18:10 joebernard

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

vishgoel007 avatar Oct 28 '20 04:10 vishgoel007

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?

joebernard avatar Oct 28 '20 11:10 joebernard

@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.

vishgoel007 avatar Oct 28 '20 12:10 vishgoel007

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);
});

jrobichaud avatar Mar 29 '21 19:03 jrobichaud