phonegap / phonegap-plugin-push

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

Notifications don't work on iOS devices #2644

Open brunojs02 opened 5 years ago

brunojs02 commented 5 years ago

Expected Behaviour

Notifications work in iOS like android devices.

Actual Behaviour

The App is connected to Firebase(I can see on analytics), but the message don't arrive, in the first time that I send a payload to firebase, I get a error status 500, and in the second time I get the error message 'identifier not found' (or something like this).. Ps: this is for development, on production always I get error status 500.

Reproduce Scenario (including but not limited to)

ionic Cordova platform add iOS ionic Cordova prepare iOS --prod open the Xcode project and change the system build, like in issue #2518. and run on my device. PS: my certs to prod and dev for provision and notifications service are on keychains and a configured a key on apple.dev account and upload to firebase.

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

iOS: 11.4.1

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

iPad Air 2

Cordova CLI version and cordova platform version

cordova --version                                     8.0.0
cordova platform version iOS                      4.5.5

Plugin version

cordova plugin version: 2.1.3

Sample Push Data Payload

Message.builder().setToken("registrationId").setApnsConfig(ApnsConfig.builder().setAps(Aps.builder().setAlert("Message teste").build()).build());

Firebase admin: 5.9.0

Sample Code that illustrates the problem

const options: PushOptions = { android: { icon: 'notificacao', iconColor: '#FF9C12' }, ios: { alert: 'true', badge: true, sound: 'true' }

};
const pushObject: PushObject = this.push.init(options);

pushObject.on('registration').subscribe((data) => {
    localStorage.setItem('registrationId', data.registrationId);
});

pushObject.on('notification').subscribe(() => {
  alert('Hello world');
});

Logs taken while reproducing problem

mreis1 commented 5 years ago

Probably related with this issue where I actually show that integrations of this plugin with iOS that rely on Google's FCM for push messages are not working. Token's returned by the plugin are invalidated and when we attempt to send the push to the device, the first time we get "InvalidRegistration" and all following attempts will return "NotRegistered".

By the away, if you use APN, this plugin will work, and you will not have the issue, but you will loose the ability to push to topics since this is a FCM feature.

brunojs02 commented 5 years ago

How u send to apns with token generated?

mreis1 commented 5 years ago

As I said this plugin allows you to work with APNs or with FCM. It depends on how you setup the plugin. If you decide to use APN, the on('registration', (token)=>) will be called with the APN token.

brunojs02 commented 5 years ago

I solve my issue removing application key from firebase and upload .p12 to dev and prod :)

mreis1 commented 5 years ago

If I understand it right, FCM is working with your iOS device?

brunojs02 commented 5 years ago

Yeah, it's working, but until now, i dont understand the reason that .p12 work for dev and prod, but .p8 dont. Ps: the warnings messages still appears when i install the app by xcode.

mreis1 commented 5 years ago

I stop using .p12 keys. Instead, I use the APN Key that can be obtained at https://developer.apple.com. Then I imported that key on my FCM project.

image

brunojs02 commented 5 years ago

I had done this too, but this is not working, I do not know why, so I imported the .p12 files to the firebase and started working normally.

andymurakami commented 5 years ago

I have the same issue, but to me not working with .p8 or dev/prod certificates. Do you found any solution ?

AppwareDev commented 5 years ago

Try this in Xcode:

File > Workspace Settings, change Build System to Legacy Build system

dvdpzzt-webmapp commented 5 years ago

I had the same problem. As @brunojs02 suggested, i removed the .p8 and switched to the .p12 certificates and now it works

vencis commented 5 years ago

Try this in Xcode:

File > Workspace Settings, change Build System to Legacy Build system

I had the same problem. This suggestion works