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

push.on('notification') not fired on resume ios 10.2 #1565

Closed
manojrejinthala opened this issue Feb 2, 2017 · 7 comments
Closed

push.on('notification') not fired on resume ios 10.2 #1565

manojrejinthala opened this issue Feb 2, 2017 · 7 comments

Comments

@manojrejinthala
Copy link

Expected Behavior

When App resume handles notification, which performs an action on receiving push notification .

Actual Behavior

App opens but handlers does not receive the notification or data.

but its working fine android and iPad(IOS version of 9) in both cased when the app is cold-start and on resume.

Even i looked at the issue raised on #1002 and #1253

Reproduce Scenario (including but not limited to)

iOS 10 beta 1
Open app (can be running through XCode so you can see output)
Press home button
Send a notification
Press the notification
App opens, view the output on XCode
Platform and Version (eg. Android 5.0 or iOS 9.2.1)

iOS 10 beta 1 on iPhone 6.

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Cordova CLI version and cordova platform version

CLI version: 6.1.1
cordova ios 4.1.1

Plugin version

1.8.4

here is my sample code .

//push notification code for getting device token.
push = PushNotification.init({
android: {
senderID: "61426985247",
sound: "true",
vibrate: "true",

            },
            browser: {
                pushServiceURL: 'http://push.api.phonegap.com/v1/push'
            },
            ios: {
                alert: "true",
                badge: true,
                sound: 'false'
            },
            windows: {}
        });
        
		//This will give the device token value
        push.on('registration', function(data) {

            $rootScope.deviceToken = data.registrationId;

        });
		
		//This function will execute when user click on push notification.
        push.on('notification', function(data) {
            alert(JSON.stringify(data));
            
        });

Please help me out to solve this problem.

@macdonst
Copy link
Member

macdonst commented Feb 2, 2017

@manojrejinthala please try the 1.9.x version of the plugin as there were some fixes for iOS 10.

@manojrejinthala
Copy link
Author

while giving the ios build it gives me the GoogleCloudMessaging.h file not found error.

how can i fix that issues with plugin with 1.9.x

@manojrejinthala
Copy link
Author

manojrejinthala commented Feb 7, 2017

I fixed the above issue @macdonst and i am successfully build the application with 1.9.2 version of push plugin still push.on('notification') not fired on resume ios 10.2 . Any other solutions to fix this issues.

@srameshr
Copy link

srameshr commented Feb 9, 2017

@manojrejinthala Hey, can you show me the json that you are sending from your server to your IOS devices?

@Honorato
Copy link

@manojrejinthala Are you sending messages from Firebase?
I had the same problem with Firebase. I solve it by sending two different payloads, one for Android devices and another to iOS devices. I had to do some other things to make it work:

  1. Include "content-available": "1" inside data;
  2. On iOS payload, include priority: 'high', at the same level of notification;
  3. For iOS devices, I had to send with notification part of the message and had to include priority: 'high', as follows:
    var message = { to: deviceID, priority: 'high', notification: { title: "Message title", body: "Message body" }, data: { action: "doSomething", "content-available": "1" } };
  4. On the other hand, for Android devices I had to send without notification part, only with data, as follows:
    var message = { to: deviceID, data: { title: "Message title", body: "Message body", action: "doSomething", "content-available": "1" } };
  5. Another important thing: remember to call PushNotification.init(config) when your app starts for the 1st time since the user has forced close it. Without it, the notification listener won't get fired.

That worked for me. I'm using version 1.9.2 of the plugin.

Hope it helps.

@macdonst
Copy link
Member

Closing, inactivity. Please comment/re-open if you have more details.

@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants