-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notification permission prompting to IAMs
Add support for notification permission prompting to In-App Messaging.
- Loading branch information
Showing
2 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessagePushPrompt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.onesignal; | ||
|
||
public class OSInAppMessagePushPrompt extends OSInAppMessagePrompt { | ||
|
||
static final String PUSH_PROMPT_KEY = "push"; | ||
|
||
@Override | ||
void handlePrompt(OneSignal.OSPromptActionCompletionCallback callback) { | ||
OneSignal.promptForPushNotifications( | ||
true, | ||
accepted -> { | ||
OneSignal.PromptActionResult result = accepted ? | ||
OneSignal.PromptActionResult.PERMISSION_GRANTED : | ||
OneSignal.PromptActionResult.PERMISSION_DENIED; | ||
callback.onCompleted(result); | ||
} | ||
); | ||
} | ||
|
||
@Override | ||
String getPromptKey() { | ||
return PUSH_PROMPT_KEY; | ||
} | ||
|
||
} |