Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiving notifications on iOS when app immediately in background #30

Closed
rwillett opened this issue Jan 6, 2016 · 16 comments
Closed

Receiving notifications on iOS when app immediately in background #30

rwillett opened this issue Jan 6, 2016 · 16 comments

Comments

@rwillett
Copy link

rwillett commented Jan 6, 2016

I am unclear if this should be asked here or on the OneSignal website. I have asked on both to be sure. Apologies if I have this wrong and its for the website help team (or vice versa).

I have a question regarding how the OneSignal notification handler responds when the IOS app has moved to background (IOS has not suspended the app yet) AND a content-available =1 notification is sent.

As the IOSapp has been in the the background for only a few minutes (or secs), I would expect the OneSIgnal handler to process the notification (which is simply to log it at the moment). Currently the handler works in foreground but not at all when the app is in the background.

Is this the expected behaviour? Experience with other notification plugins is they keep on working until the IOS app gets suspended which is some variable time that the device determines but can be up to 15 mins or so.

This is with IOS 9.2 and Xcode 7.2, onesignal-cordova-plugin 1.10.1.

Thanks,

Rob

@jkasten2
Copy link
Member

jkasten2 commented Jan 9, 2016

Hello Rob,

The notificationOpenedCallback only fires in the following 2 cases.

  • The user taps on a notification.
  • A notification is received when the app is currently in focus.

If you need to do background processing in your app as soon as the notification arrives you will need to set content_available to true on our REST API or enable this option on the dashboard when creating a new message. Enabling this does not fire the callback above, it instead wakes up your app and calls the application:didReceiveRemoteNotification:fetchCompletionHandler: selector. This selector isn't available in Cordova so you will need to write Objective-C or Swift code to handle this.

Let us know your use case for doing background work when a notification is received and we can consider adding it as an SDK feature instead of requiring you to write your own native code.

Thanks.

@rwillett
Copy link
Author

rwillett commented Jan 9, 2016

Josh,

Let me write something up for you. It’ll take a few days to put
together.

Rob

On 9 Jan 2016, at 4:46, Josh Kasten wrote:

Hello Rob,

The
notificationOpenedCallback
only fires in the following 2 cases.

  • The user taps on a notification.
  • A notification is received when the app is currently in focus.

If you need to do background processing in your app as soon as the
notification arrives you will need to set content_available to true on
our REST API or enable this option on the dashboard when creating a
new message. Enabling this does not fire the callback above, it
instead wakes up your app and calls the
application:didReceiveRemoteNotification:fetchCompletionHandler:
selector. This selector isn't available in Cordova so you will need to
write Objective-C or Swift code to handle this.

Let us know your use case for doing background work when a
notification is received and we can consider adding it as an SDK
feature instead of requiring you to write your own native code.

Thanks.


Reply to this email directly or view it on GitHub:
#30 (comment)

@jkasten2
Copy link
Member

Hey Rob,

Just checking in to see if you have more information for us. Feel free to reopen this issue with your reply.

Thanks.

@neves
Copy link

neves commented May 10, 2016

Is there any plan to implement this feature?
It was done at phonegap-plugin-push phonegap/phonegap-plugin-push#93
Here's the code:
https://github.com/phonegap/phonegap-plugin-push/blob/master/src/ios/AppDelegate%2Bnotification.m#L112

@leizard
Copy link

leizard commented Jun 3, 2016

hey @rwillett, i'm currently interested in this use case. Does onesignal go well with phonegap push plugin ?

@rwillett
Copy link
Author

rwillett commented Jun 3, 2016

We hadn't the time to try and resolve this issue using OneSignal so we used a different provider to get the functionality we needed. We don't use Phonegap push plugin at all, so can't comment. Simon McDonald the author of the push plugin may be able to advise.

Rob

@neves
Copy link

neves commented Jun 3, 2016

@leizard, OneSignal doesn't work with Phonegap push plugin.

@leizard
Copy link

leizard commented Jun 3, 2016

thanh you @rwillett and @neves for your information.

@imayolas
Copy link

@leizard Highly interested too on the implementation of
phonegap/phonegap-plugin-push#93

In our case, we'd like to use it to wake up the app and periodically get user's location.

@leizard
Copy link

leizard commented Jun 14, 2016

Hi @c990802, I'm using Ionic push and it work really good with phonegap push plugin. But I'm also interested at OneSignal and want to have a try with it.

@imayolas
Copy link

imayolas commented Jun 15, 2016

@jkasten2 Would it be possible to consider such feature for the cordova sdk?

@jkasten2
Copy link
Member

It recommend to prevent the notification from going to the device by filtering it instead of trying to keep it from displaying on the device end. This consumes extra battery to wake your device and app so it is best to avoid it if possible.

If you do need to do background work with a notification it should be done in native code as starting the Cordova run time each time a notification is received puts extra load on the device. Feel free to list your use cases here and we will see if it possible to support these natively in our SDK.

However we have fixed some compatibility issues in the 2.0.8 release of the SDK which means phonegap-plugin-push may work along side OneSignal now. Feel free to report if both work together now.

@jkasten2 jkasten2 reopened this Nov 22, 2016
@neves
Copy link

neves commented Nov 22, 2016

Thanks @jkasten2, I'll try 2.0.8 and see if I can use this feature from phonegap-plugin-push, since it's already implemented there.

@elysiopires
Copy link

Hello @neves! Was this implemented on 2.0.8? I really need this too... to maintain my Badge Updated.

Thx,
Elysio

@Nightsd01
Copy link
Contributor

Closing this issue due to inactivity. We currently do not support background notification processing in the Cordova SDK because it would require loading the Cordova runtime in the background.

We currently recommend that if you want background processing, you should use application:didReceiveRemoteNotification: and set content_available = true in iOS and implement the NotificationExtenderService in Android.

@sido420
Copy link

sido420 commented Sep 2, 2018

@Nightsd01 can you comment on #416 plz?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants