You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
Hello,
Absolutely love the idea of this package but it unfortunately no longer works. Your update categories is calling to register the app, whcih is call the registration events, which your app is listening to so that it can again register the app - therefore we have ourselves an endless loop :(
From what I can tell, this would have been broken sinc eReact Native version 0.17 when they started emitting the loop
RCT_EXPORT_METHOD(updateCategories:(NSArray *)json)
{
NSMutableArray *categories = [[NSMutableArray alloc] init];
// Create the category
for (NSDictionary *categoryJSON in json) {
[categories addObject:[self categoryFromJSON:categoryJSON]];
}
// Get the current types
UIUserNotificationSettings *settings;
UIUserNotificationType types = settings.types;
NSLog(@"Settings: %@", settings);
// Update the settings for these types
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:types categories:[NSSet setWithArray:categories]]];
}
in the code above at the end you are calling: [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:types categories:[NSSet setWithArray:categories]]];
React's official implementation listens to changes to this value:
// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
NSLog(@"Register Push!");
[RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
}
As you can see here it is then emitting the didRegister command...
This then calls the paired part in React Native's push notification implementation:
Basically, add and remove an event listener right away. Haven't tested it in production yet, but I'm now able to use the onRegister callback in react-native-push-notification
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
Absolutely love the idea of this package but it unfortunately no longer works. Your update categories is calling to register the app, whcih is call the registration events, which your app is listening to so that it can again register the app - therefore we have ourselves an endless loop :(
From what I can tell, this would have been broken sinc eReact Native version 0.17 when they started emitting the loop
in the code above at the end you are calling:
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:types categories:[NSSet setWithArray:categories]]];
React's official implementation listens to changes to this value:
As you can see here it is then emitting the didRegister command...
This then calls the paired part in React Native's push notification implementation:
It would appear the "if" is always true because REGISTER NOW loops as well.
This emits this function:
which then emits the registration event which is being listened to by updateCategories:
and thus, the loop continues, indefinitely.
The text was updated successfully, but these errors were encountered: