Uh oh!
There was an error while loading. Please reload this page.
[PushNotifications] Add an event for remote notification registration, and improve permissions request - #1304
[PushNotifications] Add an event for remote notification registration, and improve permissions request#1304andrewimm wants to merge 2 commits into
Conversation
ericvicenti
commented
May 15, 2015
@facebook-github-bot import |
facebook-github-bot
commented
May 15, 2015
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1067134919980570/int_phab to review. |
…missions to be requested
andrewimm
commented
May 15, 2015
Squashed and rebased |
ericvicenti
commented
May 19, 2015
Just tried to run this on the iPhone 6 simulator and it couldn't build. Looks like your enum is not compatible with iOS8 |
lazywei
commented
May 20, 2015
I think if this is merged, then #1176 is closable. I'm looking forward to this being merged 👍 |
There was a problem hiding this comment.
When I trying to use this fork, this line seems to be never called. Did I miss anything?
lazywei
commented
May 20, 2015
I'm not sure if I miss anything, but it seems to me the - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSMutableString *hexString = [NSMutableStringstring];
constunsignedchar *bytes = [deviceToken bytes];
for (int i = 0; i < [deviceToken length]; i++) {
[hexString appendFormat:@"%02x", bytes[i]];
}
NSDictionary *userInfo = @{
@"deviceToken" : [hexString copy]
};
[[NSNotificationCenterdefaultCenter] postNotificationName:@"RemoteNotificationsRegistered"object:selfuserInfo:userInfo];
} |
lazywei
commented
May 22, 2015
ping @ericvicenti , how is it going? |
andrewimm
commented
May 23, 2015
@ericvicenti I'm assuming your comment was a typo, since I was having no trouble running on iOS 8 in the simulator or on device, but there were linker & enum errors with iOS 7.1. I made some adjustments to get the linker to cooperate again, things are working now on 7 and 8. @lazywei you're right, you need to call the public You'll need to do the same thing if you want to respond to |
lazywei
commented
May 23, 2015
@andrewimm Great, thanks! I think this should be remarked on the doc, right? By the way, when doing this (I mean, calling |
d-vine
commented
May 31, 2015
@lazywei Being a total Objectiv-C n00b I struggled with the headers. To get it to work one needs to |
lazywei
commented
Jun 3, 2015
ping @ericvicenti how is this going? |
ericvicenti
commented
Jun 3, 2015
Sorry for all the delay on this! I'm not very familiar with iOS notifs and I had to fix an issue with iOS7/8 notif registration types. Good news is it has landed internally and will be synced to GH tomorrow morning! Thanks for all your patience on this |
d-vine
commented
Jun 4, 2015
@ericvicenti |
niftylettuce
commented
Nov 8, 2015
Can we please update the docs at https://facebook.github.io/react-native/docs/pushnotificationios.html to show users how to get a token that's already been registered? |
niftylettuce
commented
Nov 8, 2015
Figured it out - we should add a line:
|
kevinaltschuler
commented
Nov 15, 2015
I'm on 0.14.0-rc and the event doesnt seem to ever get triggered in my index.ios.js |
d-vine
commented
Nov 15, 2015
Hi @Kevtastic. Did you add the listener functions to your AppDelegate.m? |
kevinaltschuler
commented
Nov 15, 2015
i did yeah, my appdelegate looks like this right now then my js bundling stuff |
d-vine
commented
Nov 15, 2015
I think you also need to call PushNotificationIOS.requestPermissions() at least once. |
kevinaltschuler
commented
Nov 15, 2015
I'm calling requestPermissions inside of render right now, though I've tried to do it in componentWillMount and in componentDidMount. I've tried listening for the event before and after I request permissions but in both cases im not getting anything |
ivanbrens
commented
Nov 28, 2015
+1 same issue as @Kevtastic |
kevinaltschuler
commented
Jan 27, 2016
@ivanbrens As soon as I switched over to production certs and testflight it started working. I'm convinced development certificates have never worked for anyone ever. |
andrewimm
commented
Jan 27, 2016
@Kevtastic development certs definitely worked when this code landed -- otherwise, I wouldn't have been able to test it. However, Apple has never supported notification registration in a Simulator, which is probably why things never worked until you moved to a physical device. It's unfortunate, but part of the iOS development experience. Thankfully, it's much easier to deploy to a physical device these days, now that app deploys can be tied to your iCloud account. |
In order to add Push support to the Parse JS SDK in React Native, we need a way to receive the APNS device token from the JS context. This adds another event to PushNotificationIOS, so that code can respond to a successful registration.
Additionally, I've updated the
requestPermissionscall to accept an optional map of parameters. This way, developers can request a subset of user notification types.