File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
OneSignalSDK/onesignal/src/main/java/com/onesignal Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 10
10
import java .util .ArrayList ;
11
11
import java .util .List ;
12
12
13
- import static com .onesignal .OSInAppMessageLocationPrompt .LOCATION_PROMPT_KEY ;
14
-
15
13
public class OSInAppMessageAction {
16
14
17
15
private static final String ID = "id" ;
@@ -117,8 +115,14 @@ private void parseOutcomes(JSONObject json) throws JSONException {
117
115
private void parsePrompts (JSONObject json ) throws JSONException {
118
116
JSONArray promptsJsonArray = json .getJSONArray (PROMPTS );
119
117
for (int i = 0 ; i < promptsJsonArray .length (); i ++) {
120
- if (promptsJsonArray .get (i ).equals (LOCATION_PROMPT_KEY ) ) {
121
- prompts .add (new OSInAppMessageLocationPrompt ());
118
+ String promptType = promptsJsonArray .getString (i );
119
+ switch (promptType ) {
120
+ case OSInAppMessagePushPrompt .PUSH_PROMPT_KEY :
121
+ prompts .add (new OSInAppMessagePushPrompt ());
122
+ break ;
123
+ case OSInAppMessageLocationPrompt .LOCATION_PROMPT_KEY :
124
+ prompts .add (new OSInAppMessageLocationPrompt ());
125
+ break ;
122
126
}
123
127
}
124
128
}
Original file line number Diff line number Diff line change
1
+ package com .onesignal ;
2
+
3
+ public class OSInAppMessagePushPrompt extends OSInAppMessagePrompt {
4
+
5
+ static final String PUSH_PROMPT_KEY = "push" ;
6
+
7
+ @ Override
8
+ void handlePrompt (OneSignal .OSPromptActionCompletionCallback callback ) {
9
+ OneSignal .promptForPushNotifications (
10
+ true ,
11
+ accepted -> {
12
+ OneSignal .PromptActionResult result = accepted ?
13
+ OneSignal .PromptActionResult .PERMISSION_GRANTED :
14
+ OneSignal .PromptActionResult .PERMISSION_DENIED ;
15
+ callback .onCompleted (result );
16
+ }
17
+ );
18
+ }
19
+
20
+ @ Override
21
+ String getPromptKey () {
22
+ return PUSH_PROMPT_KEY ;
23
+ }
24
+
25
+ }
You can’t perform that action at this time.
0 commit comments