From 99e48084cbb091a8b4f0e790bbd0866fd0757a7e Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Wed, 9 Aug 2017 13:54:10 +0200 Subject: [PATCH] Add callback to notification usage prompt --- ios/Classes/ComWilliamrijksenOnesignalModule.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ios/Classes/ComWilliamrijksenOnesignalModule.m b/ios/Classes/ComWilliamrijksenOnesignalModule.m index 642f6e0..137a21a 100644 --- a/ios/Classes/ComWilliamrijksenOnesignalModule.m +++ b/ios/Classes/ComWilliamrijksenOnesignalModule.m @@ -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]; + } }]; }