Skip to content

Commit

Permalink
Add callback to notification usage prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen van Dijk committed Aug 9, 2017
1 parent bf28a71 commit 99e4808
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ios/Classes/ComWilliamrijksenOnesignalModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,21 @@ -(void)notificationReceived:(NSDictionary*)info

- (void)promptForPushNotificationsWithUserResponse:(id)args
{
ENSURE_UI_THREAD_1_ARG(args);
ENSURE_UI_THREAD(promptForPushNotificationsWithUserResponse, args);
ENSURE_SINGLE_ARG(args, KrollCallback);

if([args isKindOfClass:[KrollCallback class]]) {
[self replaceValue:args forKey:@"callback" notification:NO];
}

[OneSignal promptForPushNotificationsWithUserResponse:^(BOOL accepted) {
NSLog(@"[DEBUG] com.williamrijksen.onesignal User accepted notifications: %d", accepted);
if ([args isKindOfClass:[KrollCallback class]]) {
NSDictionary* event = @{
@"accepted": NUMBOOL(accepted)
};
[self fireCallback:@"callback" withArg:event withSource:self];
}
}];
}

Expand Down

0 comments on commit 99e4808

Please sign in to comment.