Closed jpakulski closed 5 years ago
Just a small followup:
I had a look at the native code that's included and removing a check for UIApplicationStateActive in the didReceiveRemoteNotification:(NSDictionary *)userInfo method fixes my problems. This is a totally naive fix as I did not check the rest of the code and don't really understand why the check was there in the first place:
push-plugin/native-src/ios/PushPlugin/PushManager.m
- (void)my_application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if (didReceiveOriginalMethod) {
void (*originalImp)(id, SEL, UIApplication *, NSDictionary *) = didReceiveOriginalMethod;
originalImp(self, @selector(application:didReceiveRemoteNotification:), application, userInfo);
}
NSLog(@"didReceiveNotification");
UIApplicationState appState = UIApplicationStateActive;
if ([application respondsToSelector:@selector(applicationState)]) {
appState = application.applicationState;
}
[Push sharedInstance].notificationMessage = userInfo;
[Push sharedInstance].isInline = YES;
[[Push sharedInstance] notificationReceived];
}
In the above code change
[Push sharedInstance].isInline = YES;
To
[Push sharedInstance].isInline = appState == UIApplicationStateActive;
This sets the "foreground" value inside the received message to a correct value.
A fix is released in nativescript-push-notifications@1.1.5
Hi,
I'm trying to incorporate background (silent) push notifications in our app. We observe the behaviour described here on iOS.
This behaviour is reproducible using the demo app.
I would expect the callback to be executed regardless of the app running in background. Apple states that the app will run for up to 30 sec (source)
When run in debug more using xcode I get a "didReceiveNotification" console message whenever a push notification is received regardless of app state but the callback is not executed until the app is focused.
Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
Reproduce
I use the following message to trigger a silent notification (but I tried many combinations of properties):
I get a "didReceiveNotification" whenever a push notification is received no matter what the app state is. I get Message received! message in your log but only when the app is focused.
Is there something anyone can hint at that can execute code while the app remains in the background?
Cheers