Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

on_notification event not fires on iOS when app is closed & user clicks on interactive button #34

Open
adamivancza opened this issue Dec 13, 2016 · 4 comments

Comments

@adamivancza
Copy link

Hi @rlepinski ,

I've an issue with the on_notification event - it not fires if the following conditions are met:

  • app closed
  • user clicks on an interactive button of the Notification (actually I've only tried with Tell Me More button).

FYI: it works fine if I just click on the notification - on_notification fires properly in this case.

I did some digging in the iOS code and I think the issue lies in either
https://github.com/globocom/react-native-ua/blob/master/ios/ReactNativeUAIOS/ReactNativeUAIOS.m#L202

or here
https://github.com/globocom/react-native-ua/blob/master/ios/ReactNativeUAIOS/ReactNativeUAIOS.m#L224

Could it be that in this case the notificationResponse.actionIdentifier is not UANotificationDefaultActionIdentifier?

@rlepinski
Copy link
Collaborator

So you have background notification actions. If its background the app will not launch, instead its suppose to be handled internally. I assume the react framework will not be ready to receive events if thats the case.

@rlepinski
Copy link
Collaborator

@adamivancza
Copy link
Author

So here is what I tried to achieve:

  • I'm sending a notification from UA with a button called Tell Me More. https://postimg.org/image/l6wlzv1c7/
  • When user receives the notification he should press that button to app opens the deep link associated with the button.
  • This is not working when the app is closed. Actually what happens is :
  1. since notificationResponse.actionIdentifier is not UANotificationDefaultActionIdentifier it sets the event to receivedBackgroundNotificationActionButton
  2. it goes to handleNotification method which then fires the receivedNotification event
  3. nothing happens since no one is subscribed to that event yet because app was closed and JS code is not even launched.

With my modification the following happens:

  1. notificationResponse.actionIdentifier is more_info => event set to launchedFromNotification
  2. it goes to handleNotification method which saves the notification
  3. when JS code launches I can get the notification when I invoke the ReactNativeUA.handle_background_notification() method.

@kulyk
Copy link

kulyk commented Jan 30, 2017

For background processing:

Try sending push notifications with content-available: 1 param

Provide this key with a value of 1 to indicate that new content is available. Including this key and value means that when your app is launched in the background or resumed, application:didReceiveRemoteNotification:fetchCompletionHandler: is called.

If you use Urban Airship's Engage service, you can switch it on 'Delivery' page in iOS section. It is called 'Background Processing'.

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

No branches or pull requests

3 participants