phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

ios not receive notifications #2147

Open S3r3n4 opened 6 years ago

S3r3n4 commented 6 years ago

Expected Behaviour

Receive notification on android and ios.

Actual Behaviour

Can't receive notification on ios.

Reproduce Scenario (including but not limited to)

push.on('registration', (data) => { });  //work fine, and I receive the device_token.

when I send the notification,

 push.on('notification', (data) => {
         console.log('push notification data=',data);
 }); not receive the notification.

On Android every things work fine.

Platform and Version

iOS > 9.0

Cordova CLI version and cordova platform version

cordova --version                                       7.0.1
cordova platform version android             6.2.3
cordova platform version ios                     4.4.0

Plugin version

cordova plugin version | grep phonegap-plugin-push  2.0.0-rc5

Sample Push Data Payload

The payload of notification is:

array(2) {
["aps"]=>
        array(3) {
                    ["alert"]=>
                    string(9) "Messaggio"
                    ["sound"]=>
                    string(7) "default"
                    ["badge"]=>
                            int(1)
                }
["broker"]=>
            array(3) {
                ["type"]=>
                string(4) "chat"
                ["broker_id"]=>
                string(7) "chat_id"
                ["message"]=>
                string(9) "Messaggio"
            }
}
TimothyFehr commented 6 years ago

I have the same issue, let me know what you need i will then try to reproduce it (we have multiple iPhones with different iOS versions here), What i can tell so far is that it doesn't matter if i run it on a iOS 10 or iOS 11 phone, while the same Code runs on Android just fine.

Cordova: 7.1.0 IOS: 4.5.4 Android: 6.3.0

I have only installed your pushPlugin@2.1.1.

I have no errors in the web-console, but in the XCode console i see this: 2018-01-17 12:46:05.083128+0100 pushPluginTest[284:21875] [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add [FIRApp configure]; (FirebaseApp.configure() in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8. 2018-01-17 12:46:05.109191+0100 pushPluginTest[284:21875] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40005000 started 2018-01-17 12:46:05.109253+0100 pushPluginTest[284:21875] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r) 2018-01-17 12:46:05.390509+0100 pushPluginTest[284:21881] [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at: https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging to ensure proper integration.

if you need it i can provide you the demo app.

macdonst commented 6 years ago

@TimothyFehr link to the sample repo would help.

S3r3n4 commented 6 years ago

Hi, thanks for your reply, I think that my problem on IOS is this: when i call

PushNotification.hasPermission( function(data){ console.log('hasPermission data='+ JSON.stringify(data)); });

I receive this: data={"isEnabled":false}

how can I activate the plugin on ios?

On firebase console I had:

schermata 2018-01-18 alle 09 43 33

and I built the app in production mode with these certificates:

on my mac:

schermatagithub

on apple.developer:

schermatagithub2

What I can do to receive push notification on ios?

S3r3n4 commented 6 years ago

I had called: PushNotification.hasPermission( function(data){ console.log('hasPermission data='+ JSON.stringify(data)); });

after accepted the push notification permission on device, now I have data={"isEnabled":true}

but notification not arrive

macdonst commented 6 years ago

@S3r3n4 how are you sending that push? Is it via APNS or FCM?

TimothyFehr commented 6 years ago

Here is the link to the repo: https://github.com/TimothyFehr/pushPluginTest

I am trying to do it directly with FCM.

Thanks a lot for your help and time

S3r3n4 commented 6 years ago

Hi @macdonst, thanks again for your help, I'm sending the push by APNS

macdonst commented 6 years ago

@S3r3n4 can you run the app from within Xcode and see what logs you get?

macdonst commented 6 years ago

@TimothyFehr nothing looks wrong with your test project. One thing I noticed is that the sender ID in the index.js does not match the sender ID in the .pList. More often than not it is an issue with the signing certs when messages don't arrive on iOS.

yashaswini commented 6 years ago

Has anyone found a solution for this. Even am facing same issue.

kams2160 commented 6 years ago

I have the same issue. Android works fine but the same app on iOS not receive notifications.

rizwanzaheer commented 6 years ago

@macdonst I have the same issue. Android works fine but the same app on iOS not receive notifications using FCM.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

alexstanbury commented 6 years ago

Same issue for me, been trying to get it going for 3 hours now.

tleguijt commented 6 years ago

Could this be related to https://github.com/firebase/quickstart-ios/issues/327 ?

macdonst commented 6 years ago

Folks getting a push message to an Apple device is not as easy as it is on Google because of the way they separate development and productions servers for APNS. Most often people will sign the app as dev and send via the production APNS or vice versa so you get a registration ID but not one that works on the sever you are sending it to. My advice is to double check that setting, then check it again.

alexstanbury commented 6 years ago

Can you possibly point me in the direction of a good resource that explains step by step how to ensure everything is set up properly in terms of dev/production environments?

Edit: after further research it's clear that the dev/prod certificate issue is irrelevant for me as I am using the Auth key method as recommended by both apple and firebase.