{
desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
stationaryRadius: 5,
distanceFilter: 10,
debug: false,
startOnBoot: false,
startForeground: false,
stopOnTerminate: true,
stopOnStillActivity: false
}
When using in conjunction with react-native-push-notification or PushNotificationIOS, react-native-background-geolocation brings notifications in the foreground, and triggers the completion handler.
I don't understand Objective C very well, but it looks like the bug appeared in b29c4462099ce0e2e38f8a04f194e3b95b90d05e: completionHandler is called for iOS 10, for any notification.
If I comment out the lines below, it works as expected.
+ // if (@available(iOS 10, *)) {
+ // UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
+ // center.delegate = self;
+ // }
Using standard React Native push notifications in iOS, the notification is not expected to be displayed when the app is on the foreground.
Remote push notifications are displayed when app is in the foreground.
When using debug: true, the completionHandler should not be called.
Moreover, the library should not intercept remote push notifications sent from other sources.
Maybe add some metadata to the local notification and call the completion handler only for notifications sent by the plugin itself?
You've summed it up, pretty nicely.
This "behaviour" was introduced with intention to show show debug messages also when app is in foreground (which was default behaviour in iOS < 10).
As you suggested, some message identification needs to be added, to not display messages that didn't come from the plugin.
Thank you for your response.
As a workaround, I forked the repository and commented out the lines calling the completion handler.
I don't think I can be very helpful on this, I don't speak Objective C 馃槓
This also prevents the push notifications from being sent to the app. As when specifying a delegate for UNUserNotificationCenter, you prevent the default app delegate functions from being called.
It took me hours to understand what broke my notifications...
@danielgindi does your commit 7685972814fe25ca9ccbc4c9777124ccca6f7844 fix the problem?
Yes it does