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

push.on('registration') event not called on IOS. #752

Closed
sethannabel opened this issue Mar 24, 2016 · 16 comments
Closed

push.on('registration') event not called on IOS. #752

sethannabel opened this issue Mar 24, 2016 · 16 comments
Labels

Comments

@sethannabel
Copy link

Expected Behaviour

I've recently started developing against this plugin starting with version 1.6 and now 1.6.1. When I startup my app I expect push.on('registration') to be called on IOS and Android so I can capture the registrationId and send it to my backend server. push.on('registration') isn't called on IOS, but works fine on Android.

Actual Behaviour

On IOS I don't see push.on('registration') being called, but I do on Android.

Reproduce Scenario

Install push plugin and sample code on Cordova app and run on IOS device, startup app and look at logs to confirm, do same on Android device and

Platform and Version

IOS 9.3 on Iphone 6 and on IOS 8.3 on Iphone 5 - not working on either
Android 6.01 on Nexus 5 - working

System Info

ionic info

Your system information:

Cordova CLI: 6.0.0
Gulp version: CLI version 3.8.11
Gulp local: Local version 3.9.0
Ionic Version: 1.2.4-nightly-1917
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.2
ios-sim version: 3.1.1
OS: Mac OS X El Capitan
Node Version: v0.12.7
Xcode version: Xcode 7.3 Build version 7D175

Cordova CLI version and cordova platform version

cordova --version
6.0.0

cordova platform
Installed platforms: android 5.1.1, browser 4.0.0, ios 4.1.0

Plugin version

cordova plugin version | grep phonegap-plugin-push
phonegap-plugin-push 1.6.1 "PushPlugin"

Sample Push Data Payload

NA

Sample Code that illustrates the problem

https://gist.github.com/sethannabel/68ae83a338ad4bc1eb6e

Logs taken while reproducing problem

https://gist.github.com/sethannabel/496aa1a8d4bcd1be900b

@ghost
Copy link

ghost commented Mar 24, 2016

I have the same setup and the same issue on an iPhone 5s with iOs 9.3

@macdonst macdonst added the ios label Mar 24, 2016
@macdonst
Copy link
Member

@sethannabel and @s4lesman do you have a certificate from Apple with push enabled? The ID of that certificate should match the ID of your project which is used as XCode's bundle identifier.

@sethannabel
Copy link
Author

I do. You can see from my ios log sample gist that the plugin actually logs the token it gets back from the Apple APN_SANDBOX.

2016-03-24 09:36:03.583 myapp[764:254130] Push Plugin register success: <d261b86f 8edd7172 e9f70063 6c91f201 de959ef8 3f444802 ad8e4ab2 bc699cd2>

I can also use the APN Tester tool

https://itunes.apple.com/us/app/apn-tester-free/id626590577?mt=12

to manually send a notification to my device if I copy the token that I see in the logs. It seems that the plugin is just not calling my push.on('registration') event which I need to gain access to the token programmatically.

Attached screenshots from my iPhone and APN Tester Tool. Since I'm seeing the token in the logs I believe my Apple Certificates are setup correctly in Xcode and my project.

NotificationTestScreenshot.pdf
APNTesterScreenshot.pdf

@panaggio
Copy link

I had the several similar problems yesterday using cutting edge Xcode, iOS, cordova, .... I've downgraded a lot of stuff after that, and now on iOS 9.2.1 and Xcode 7.2 this doesn't happen anymore. I'm still using cordova 6.1 and version 1.6.0 (1.6.1?) of the plugin.

As I saw you saying iOS 9.3, so I'm here to alert about Xcode, that might be on the latest version.

It seems there are some issues related to Xcode 7.3 (and maybe iOS 9.3) with cordova itself. (That's me saying that; I didn't see a lot of people saying, just my experience using it on the past two days, before the downgrade). So your issue might be not related with the plugin itself (as mine weren't). I've reported one on cordova that I'm sure is related to ios-deploy or cordova-cli, and I'm investigating the others to report on the right place.

But this doesn't mean that the issue isn't really here. Just some advice about using Xcode 7.3 right now.

@macdonst
Copy link
Member

@sethannabel why are you calling unregister right after init?

https://gist.github.com/sethannabel/68ae83a338ad4bc1eb6e#file-gistfile1-txt-L23

@ghost
Copy link

ghost commented Mar 25, 2016

@macdonst yes I do, and I dont do the unregister. Ive double checked xcode and the push service, I am able to register with GCM , I get the token, but then when I use it on the API end, it does not get to the phone. It does get to the Android device...

@macdonst
Copy link
Member

@sethannabel I'm just saying if you try to run that example code it will invalidate the token.

@ghost
Copy link

ghost commented Mar 25, 2016

I fixed my problem by filling everything on the push object.

@sethannabel
Copy link
Author

Commenting out unregister in my code fixed the problem. Thanks for the help!

@lucasabba
Copy link

Exactly what does it mean that I need to fill everything on the push object?
Thanks to all!

@oussaki
Copy link

oussaki commented Apr 6, 2016

@macdonst brother , can you please tell us the correct steps to setup push notifications for IOS , because it works on android so good but in ios it doesn't , thank you

@macdonst
Copy link
Member

macdonst commented Apr 8, 2016

@oussaki follow Tim's excellent guide at setting up your Apple Certificates https://github.com/timkim/phonegap-day-workshop-app-submission/wiki/packaging#ios

Just remember to enable push when you generate your cert.

@oussaki
Copy link

oussaki commented Apr 24, 2016

@macdonst Im i supposed to sign the app with a cert before trying to run it on the simulator ?
because the onRegister function is never called in the simulator .

@macdonst
Copy link
Member

@oussaki yes, without a cert you won't get pushes. Also, test on a real device, not the iOS simulator as you won't get pushes.

@bandhavya
Copy link

I have the same issue

We are trying push notification for IOS but Register event is not getting called

My code:

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

push.on('registration', function(data) {
alert(data.registrationId);
});

@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

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

No branches or pull requests

6 participants