React-native-push-notification: [ios] onRegister doesn't execute

Created on 29 Mar 2017  路  6Comments  路  Source: zo0r/react-native-push-notification

I see the "allow/deny" popup when I request permissions,

PushNotification.requestPermissions();

but the config binding never executes..

    PushNotification.configure({
      onRegister: function(token) {
        console.log( 'TOKEN:', token );
      },

if I choose allow, I can schedule a notification, and it works:

  PushNotification.localNotificationSchedule({
          message: "Test Reminder", // (required)
          date: new Date(Date.now() + (60 * 1000)) // in 60 secs
        });

Any thoughts would be greatly appreciated..

PS. I know the example code is incomplete...

Most helpful comment

Simple fix that I missed.

Push toggle in capabilities settings.. derp.

screen shot 2017-03-28 at 8 05 23 pm

All 6 comments

I also put NSLog into the functions that I thought would matter, but they don't even log?

// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
  NSLog(@"on_register_notification_settings: %@", notificationSettings);
  [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  NSLog(@"on_register: %@", deviceToken);
  [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
                                                      fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
   [RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  NSLog(@"on_register_error: %@", error);
  [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
  [RCTPushNotificationManager didReceiveLocalNotification:notification];
}

Nvmd second one, OS_ACTIVITY_MODE was disabled.

So, seems it's an issue with my cert:

2017-03-28 19:58:41.475 [info][tid:com.facebook.react.JavaScript] 'check permissions', { alert: 0, badge: 0, sound: 0 }
2017-03-28 19:58:41.475253-0500 TeamHop[1228:311648] 'check permissions', { alert: 0, badge: 0, sound: 0 }
2017-03-28 19:58:53.332294-0500 TeamHop[1228:311570] on_register_notification_settings: <UIUserNotificationSettings: 0x174430e60; types: (UIUserNotificationTypeAlert UIUserNotificationTypeBadge UIUserNotificationTypeSound);>
2017-03-28 19:58:53.334904-0500 TeamHop[1228:311570] on_register_error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo={NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}

Simple fix that I missed.

Push toggle in capabilities settings.. derp.

screen shot 2017-03-28 at 8 05 23 pm

Was having this issue as well, but then realized that simulator won't show token. Worked on device.

Yes, wont' show on simulator because it has no device token.

Was this page helpful?
0 / 5 - 0 ratings