Skip to content

Commit 20c3efa

Browse files
committed
Add new features to IAM preview
* Add prompt to IAM preview * Add logs for tags and outcomes * Redisplay, tags, outcomes, impression should not be included on IAM preview
1 parent a7a9976 commit 20c3efa

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/LocationGMS.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ else if (permissionList.contains("android.permission.ACCESS_COARSE_LOCATION")) {
208208
requestPermission = "android.permission.ACCESS_COARSE_LOCATION";
209209
}
210210

211+
// We handle the following cases:
212+
// 1 - If needed and available then prompt for permissions
213+
// - Request permission can be ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION
214+
// 2 - If the permission were already granted then start getting location
215+
// 3 - If permission wasn't granted then trigger fail flow
216+
//
217+
// For each case, we call the prompt handlers
211218
if (requestPermission != null && promptLocation) {
212219
PermissionsActivity.startPrompt();
213220
} else if (locationCoarsePermission == PackageManager.PERMISSION_GRANTED) {

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageController.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void onMessageActionOccurredOnMessage(@NonNull final OSInAppMessage message, @No
273273
action.firstClick = message.takeActionAsUnique();
274274

275275
firePublicClickHandler(action);
276-
showPrompts(message, action.prompts);
276+
beginProcessingPrompts(message, action.prompts);
277277
fireClickAction(action);
278278
fireRESTCallForClick(message, action);
279279
fireTagCallForClick(action);
@@ -285,19 +285,31 @@ void onMessageActionOccurredOnPreview(@NonNull final OSInAppMessage message, @No
285285
action.firstClick = message.takeActionAsUnique();
286286

287287
firePublicClickHandler(action);
288+
beginProcessingPrompts(message, action.prompts);
288289
fireClickAction(action);
290+
logInAppMessagePreviewActions(action);
289291
}
290292

291-
private void showPrompts(OSInAppMessage message, final List<OSInAppMessagePrompt> prompts) {
293+
private void logInAppMessagePreviewActions(final OSInAppMessageAction action) {
294+
if (action.tags != null)
295+
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "Tags detected inside of the action click payload, ignoring because action came from IAM preview:: " + action.tags.toString());
296+
297+
if (action.outcomes.size() > 0)
298+
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "Outcomes detected inside of the action click payload, ignoring because action came from IAM preview: " + action.outcomes.toString());
299+
300+
// TODO: Add more action payload preview logs here in future
301+
}
302+
303+
private void beginProcessingPrompts(OSInAppMessage message, final List<OSInAppMessagePrompt> prompts) {
292304
if (prompts.size() > 0) {
293305
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "IAM showing prompts from IAM: " + message.toString());
294306
// TODO until we don't fix the activity going forward or back dismissing the IAM, we need to auto dismiss
295307
WebViewManager.dismissCurrentInAppMessage();
296-
handleMultiplePrompts(message, prompts);
308+
showMultiplePrompts(message, prompts);
297309
}
298310
}
299311

300-
private void handleMultiplePrompts(final OSInAppMessage message, final List<OSInAppMessagePrompt> prompts) {
312+
private void showMultiplePrompts(final OSInAppMessage message, final List<OSInAppMessagePrompt> prompts) {
301313
for (OSInAppMessagePrompt prompt : prompts) {
302314
// Don't show prompt twice
303315
if (!prompt.hasPrompted()) {
@@ -314,7 +326,7 @@ private void handleMultiplePrompts(final OSInAppMessage message, final List<OSIn
314326
public void completed(boolean accepted) {
315327
currentPrompt = null;
316328
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "IAM prompt to handle finished accepted: " + accepted);
317-
handleMultiplePrompts(message, prompts);
329+
showMultiplePrompts(message, prompts);
318330
}
319331
});
320332
} else {

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageOutcome.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,13 @@ public boolean isUnique() {
6060
public void setUnique(boolean unique) {
6161
this.unique = unique;
6262
}
63+
64+
@Override
65+
public String toString() {
66+
return "OSInAppMessageOutcome{" +
67+
"name='" + name + '\'' +
68+
", weight=" + weight +
69+
", unique=" + unique +
70+
'}';
71+
}
6372
}

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageTag.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,12 @@ public JSONArray getTagsToRemove() {
5050
public void setTagsToRemove(JSONArray tagsToRemove) {
5151
this.tagsToRemove = tagsToRemove;
5252
}
53+
54+
@Override
55+
public String toString() {
56+
return "OSInAppMessageTag{" +
57+
"adds=" + tagsToAdd +
58+
", removes=" + tagsToRemove +
59+
'}';
60+
}
5361
}

0 commit comments

Comments
 (0)