@@ -279,8 +279,7 @@ private void userProvidedPrivacyConsent(MethodCall call, Result reply) {
279
279
280
280
private void promptPermission (MethodCall call , Result result ) {
281
281
boolean fallback = call .argument ("fallback" );
282
- OneSignal .promptForPushNotifications (fallback );
283
- replySuccess (result , null );
282
+ OneSignal .promptForPushNotifications (fallback , new OSFlutterPromptForPushNotificationPermissionResponseHandler (messenger , channel , result , "promptPermission" ));
284
283
}
285
284
286
285
private void getDeviceState (Result reply ) {
@@ -568,6 +567,22 @@ public void onFailure(OneSignal.ExternalIdError error) {
568
567
}
569
568
}
570
569
570
+ static class OSFlutterPromptForPushNotificationPermissionResponseHandler extends OSFlutterHandler
571
+ implements OneSignal .PromptForPushNotificationPermissionResponseHandler {
572
+ OSFlutterPromptForPushNotificationPermissionResponseHandler (BinaryMessenger messenger , MethodChannel channel , Result res , String methodName ) {
573
+ super (messenger , channel , res , methodName );
574
+ }
575
+
576
+ @ Override
577
+ public void response (boolean accepted ) {
578
+ if (this .replySubmitted .getAndSet (true )) {
579
+ OneSignal .onesignalLog (OneSignal .LOG_LEVEL .DEBUG , "OneSignal " + methodName + " handler called twice, ignoring! response" );
580
+ return ;
581
+ }
582
+ replySuccess (result , accepted );
583
+ }
584
+ }
585
+
571
586
static class OSFlutterPostNotificationHandler extends OSFlutterHandler
572
587
implements OneSignal .PostNotificationResponseHandler {
573
588
0 commit comments