phonegap / phonegap-plugin-push

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

[v2.0.x] FCM: iOS no notification #1287

Closed dannywillems closed 7 years ago

dannywillems commented 8 years ago

Expected Behaviour

Notification in iOS

Actual Behaviour

Nothing

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

iOS 9

Cordova CLI version and cordova platform version

$> cordova --version
6.3.1
$> cordova platform version ios
4.2.1

Plugin version

branch v2.0.x

Sample Push Data Payload

Just a title and a message in a data section.

Sample Code that illustrates the problem

It's in OCaml with a binding and other libraries.

Logs taken while reproducing problem

Using FCM Notification
2016-10-13 18:04:31.494 mobilePush[2632:1487752] Using FCM Sandbox
2016-10-13 18:04:31.519 mobilePush[2632:1487729] Configuring the default app.
2016-10-13 18:04:31.541: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-10-13 18:04:31.547 mobilePush[2632:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started
2016-10-13 18:04:31.548: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"
2016-10-13 18:04:31.553 mobilePush[2632:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/Y0Yjwu)
2016-10-13 18:04:31.555: <FIRMessaging/INFO> FIRMessaging library version 1.1.0
2016-10-13 18:04:31.569: <FIRMessaging/WARNING> FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-10-13 18:04:31.575 mobilePush[2632:1487729] FCM Registration Token:
xxxxx
2016-10-13 18:04:31.584: <FIRInstanceID/WARNING> APNS Environment in profile: development
2016-10-13 18:04:31.586 mobilePush[2632:1487729] Push Plugin register success: <7d746878 d60ff46c 366e99be de049b0d 3476eb3d 5fd3dba8 b2d4b45a ce955b74>
2016-10-13 18:04:31.617 mobilePush[2632:1487729] Push Plugin register success: <7d746878 d60ff46c 366e99be de049b0d 3476eb3d 5fd3dba8 b2d4b45a ce955b74>
2016-10-13 18:04:31.661 mobilePush[2632:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2016-10-13 18:04:31.686 mobilePush[2632:] <FIRAnalytics/INFO> Firebase Analytics enabled
2016-10-13 18:05:10.812 mobilePush[2632:1487729] active
2016-10-13 18:05:10.812 mobilePush[2632:1487729] PushPlugin skip clear badge

I suppose it comes from:

2016-10-13 18:04:31.548: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"

It's working on Android.

jcesarmobile commented 8 years ago

That error appears when something is not configured properly, might be your apple certificates on firebase console or your provisioning profile doesn't include the push notifications, or you didn't use the same bundle identifier on the app and on firebase. Are you testing on Xcode 7 or Xcode 8?

dannywillems commented 8 years ago

@jcesarmobile Can't be that because it's working with another plugin. If there's an error with the bundle identifier, it is another error message. I'm using Xcode 7.

jcesarmobile commented 8 years ago

I could reproduce your issue and it was because I didn't upload the certificate .p12 to the firebase console, but as soon as I uploaded it, it worked, I received the FCM token push instead of the Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"

dannywillems commented 8 years ago

@jcesarmobile I uploaded the certificate and it's working with the plugin cordova-plugin-fcm. screen shot 2016-10-14 at 09 53 15

I get the FCM token and when I send a notification with my server (using ocsigen-start, see PR 199), I receive a successful message, but no notifications on the device, although I receive the notification on my Android device.

dannywillems commented 8 years ago

@jcesarmobile Is the production certificate mandatory? I suppose the iOS options are the same so:

var push = PushNotification.init({
    ios: {
        senderID: "xxxxx",
        gcmSandbox: true
    }
}); 

suffices, no?

jcesarmobile commented 8 years ago

You also have to pass alert: "true", badge: "true", sound: "false" to the init method

var push = PushNotification.init({
    ios: {
        senderID: "xxxxx",
        gcmSandbox: true,
        alert: "true", 
        badge: "true", 
        sound: "false"
    }
}); 

production certificate is mandatory only to test on production, you don't need to upload it to make it work

dannywillems commented 8 years ago

@jcesarmobile Why is it said it's optional in this case...?

Eccenux commented 7 years ago

@dannywillems Use FCM branch https://github.com/phonegap/phonegap-plugin-push/tree/FCM v2.0 branch doesn't work with FCM.

dannywillems commented 7 years ago

@Eccenux In the discussion about FCM support, it is recommended to use v2.0.x...

Eccenux commented 7 years ago

@dannywillems You're right. v2.0.x branch has some code for iOS Firebase support, while FCM branch doesn't even have proper token getter. Still I was unable to get iOS to work.

dannywillems commented 7 years ago

@jcesarmobile Are you sure it's working on iOS...? We tested a lot of time with certificates but nothing works.

tranhai commented 7 years ago

I have the same issue, always receive invalid registration token

dannywillems commented 7 years ago

@tranhai It's not the same issue than me because I have a success response from Google. Your issue comes from a bad token you use server-side.

dannywillems commented 7 years ago

So we succeed by giving a title and a body in the notification key. But the notification on Android has changed. @jcesarmobile Do you have any why? Is it mandatory to send different payload for different platforms?

jcesarmobile commented 7 years ago

@dannywillems I tested sending the push notifications from the Firebase console instead of using my own server to send the push, so I didn't really use any payload to test, it's generated from the console. I'll test using my own server and let you know

alexkushnarov commented 7 years ago

it works for me on ios, I added development certificate to firebase and I'm using v2.0.x branch

                    push = PushNotification.init({
                        android: {
                            senderID: SERVER_KEYS.FCM_SENDER_ID
                        },
                        ios: {
                            senderID: SERVER_KEYS.FCM_SENDER_ID,
                            gcmSandbox: SERVER_KEYS.BUILD_ENVIRONMENT === 'development',
                            alert: 'true',
                            badge: 'true',
                            sound: 'true'
                        },
                        windows: {}
                    });

to send notifications I'm using https://www.npmjs.com/package/fcm-push

jcesarmobile commented 7 years ago

@pramodwerea no, it's not possible as v2.0.x uses hooks and phonegap build doesn't support them

lock[bot] commented 6 years ago

This thread has been automatically locked.