Uh oh!
There was an error while loading. Please reload this page.
[Pushnotifications] Add error event - #2336
Conversation
PhilippKrone
commented
Sep 13, 2015
@ide Do you have any information here about whether this is going to get merged or any chance you could review this? |
anthonywebb
commented
Sep 16, 2015
I need this as well, hoping push notifications can be properly supported in react, seems kind of half baked and broken in its current state. |
DannyvanderJagt
commented
Sep 17, 2015
@PhilippKrone They are a little busy with the android release at the moment I think. But it would be nice if this could be merged/reviewed. @ide Let us/me know if we can help you. @anthonywebb push notifications are working in React-Native for IOS when you apply the fix from this PR. I have written a tutorial about How to use push notifications in React-Native., it also includes the instructions to apply that fix to your project. Besides the push notifications, there are some issues and PRs for local notifications in IOS but nothing is merged yet (as far I know). |
justinmakaila
commented
Oct 14, 2015
This is great. I'd love for this to be integrated. Any estimates? |
JonnyBGod
commented
Oct 26, 2015
+1 |
DannyvanderJagt
commented
Oct 28, 2015
@justinmakaila There is not estimate. The React-Native team is very busy at the moment. I will update and rebase this PR this weekend to get it up to date. |
jadsonlourenco
commented
Nov 5, 2015
+1 |
satya164
commented
Dec 27, 2015
@DannyvanderJagt Any updates on this? |
basketofsoftkittens
commented
Jan 14, 2016
+1 |
satya164
commented
Jan 26, 2016
Closing since no activity on the PR. let's re-open if you wanna work on it again. |
niftylettuce
commented
May 20, 2016
Can we get this in? |
niftylettuce
commented
May 20, 2016
If anyone else needs something temporary, add this to your |
DannyvanderJagt
commented
May 20, 2016
@niftylettuce Yes of course we can get this in. I will revisit this PR this weekend and hopefully it will get merged soon. I'm sorry for the big delay but I just got slammed with work the last few months. |
DannyvanderJagt
commented
May 23, 2016
I couldn't get the old branch updated without destroying this PR. I forked the master of react-native today and added back and updated all the code of the this PR. See: #7694 @niftylettuce Thank you for reminding me :) |
Summary: This is an updated version of #2336 and #7694. --- This adds a `registrationError` event that is emitted by `PushNotificationIOS` whenever an application receives a registration error from APNS (APNS service failure, running on simulator, etc). This event fires to the exclusion of the `register` event (and vice versa). **How to use** Add the following to your `AppDelegate.m`: ```obj-c - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error]; } ``` And register an event handler for the event: ```js PushNotificationIOS.addEventListener('registrationError', function({ message, code }) { // Complete your registration process in error. }); ``` **Test plan** Added support for this event (and `register`) to UIExplorer as a proof of concept. Navigating to the push notifications example on a simulator is an easy way to reproduce this e Closes#9650 Differential Revision: D3822142 Pulled By: javache fbshipit-source-id: a15ed8941b74dc3eed2c44c658deccbcaf39ce3d
Summary: This is an updated version of react#2336 and react#7694. --- This adds a `registrationError` event that is emitted by `PushNotificationIOS` whenever an application receives a registration error from APNS (APNS service failure, running on simulator, etc). This event fires to the exclusion of the `register` event (and vice versa). **How to use** Add the following to your `AppDelegate.m`: ```obj-c - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error]; } ``` And register an event handler for the event: ```js PushNotificationIOS.addEventListener('registrationError', function({ message, code }) { // Complete your registration process in error. }); ``` **Test plan** Added support for this event (and `register`) to UIExplorer as a proof of concept. Navigating to the push notifications example on a simulator is an easy way to reproduce this e Closesreact#9650 Differential Revision: D3822142 Pulled By: javache fbshipit-source-id: a15ed8941b74dc3eed2c44c658deccbcaf39ce3d
This PR will add an
errorevent toPushNotificationIOS.How it works
When something goes wrong with the Push notifications, for example running on a simulator or when the certificates aren't configured the right way, IOS will create an error and pass it to
didFailToRegisterForRemoteNotificationsWithError. This error consists out of an key and a message. This error is passed down from IOS to Js and when there is an error event registered in JS it will pass the error. When there isn't an error event registered nothing will happen.Why is this useful?
At the moment
PushNotificationIOSfails silently and there is no way of telling if something went wrong. Therefore some people are having trouble to get push notifications working in react-native.How to use
The error event can be used just like the
registerand thenotificationevent.The error callback will give the error
messageand the errorkey. Both are the original IOS error.And add this to the
AppDelegate.mbesides the normal pushnotifications code:Similar PR
A similar solution PR exists: #1019
This PR uses a callback as a parameter in
requestPermissionsand it will give you a token or an error.I prefer the solution is this PR because it is:
References
This PR was part of #1979 and it is discussed here: #1613.
This event should be added to the docs. Can anyone tell me how accomplish this?
Please let me know what you think.