Skip to content

Commit 1f81490

Browse files
committed
Switching to constants keys from strings
1 parent c98230f commit 1f81490

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
* */
5959
class NotificationBundleProcessor {
6060

61-
private static final String PUSH_ADDITIONAL_DATA_KEY = "a";
61+
public static final String PUSH_ADDITIONAL_DATA_KEY = "a";
6262

6363
public static final String PUSH_MINIFIED_BUTTONS_LIST = "o";
6464
public static final String PUSH_MINIFIED_BUTTON_ID = "i";

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// Future: This class could also support parsing our SDK generated bundles
1212
class OSNotificationFormatHelper {
1313

14-
static final String PAYLOAD_OS_ROOT_CUSTOM = "custom";
15-
private static final String PAYLOAD_OS_NOTIFICATION_ID = "i";
14+
public static final String PAYLOAD_OS_ROOT_CUSTOM = "custom";
15+
public static final String PAYLOAD_OS_NOTIFICATION_ID = "i";
1616

1717
static boolean isOneSignalIntent(@Nullable Intent intent) {
1818
if (intent == null)

OneSignalSDK/unittest/src/test/java/com/onesignal/OneSignalPackagePrivateHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,6 @@ public static class JSONUtils extends com.onesignal.JSONUtils {
530530
public static class GenerateNotification extends com.onesignal.GenerateNotification {}
531531

532532
public static class NotificationBundleProcessor extends com.onesignal.NotificationBundleProcessor {}
533+
534+
public static class OSNotificationFormatHelper extends com.onesignal.OSNotificationFormatHelper {}
533535
}

OneSignalSDK/unittest/src/test/java/com/test/onesignal/NotificationOpenedActivityHMSIntegrationTestsRunner.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232

3333
import java.util.UUID;
3434

35+
import static com.onesignal.OneSignalPackagePrivateHelper.NotificationBundleProcessor.PUSH_ADDITIONAL_DATA_KEY;
36+
import static com.onesignal.OneSignalPackagePrivateHelper.OSNotificationFormatHelper.PAYLOAD_OS_ROOT_CUSTOM;
37+
import static com.onesignal.OneSignalPackagePrivateHelper.OSNotificationFormatHelper.PAYLOAD_OS_NOTIFICATION_ID;
3538
import static com.onesignal.OneSignalPackagePrivateHelper.GenerateNotification.BUNDLE_KEY_ACTION_ID;
3639
import static com.onesignal.InAppMessagingHelpers.ONESIGNAL_APP_ID;
3740
import static com.test.onesignal.RestClientAsserts.assertNotificationOpenAtIndex;
@@ -57,6 +60,8 @@
5760
@RunWith(RobolectricTestRunner.class)
5861
public class NotificationOpenedActivityHMSIntegrationTestsRunner {
5962

63+
private static final String TEST_ACTION_ID = "myTestActionId";
64+
6065
@BeforeClass // Runs only once, before any tests
6166
public static void setUpClass() throws Exception {
6267
ShadowLog.stream = System.out;
@@ -79,19 +84,19 @@ public void beforeEachTest() throws Exception {
7984
private static @NonNull Intent helper_basicOSHMSOpenIntent() throws JSONException {
8085
return helper_baseHMSOpenIntent()
8186
.putExtra(
82-
"custom",
83-
new JSONObject() {{
84-
put("i", UUID.randomUUID().toString());
85-
}}.toString()
87+
PAYLOAD_OS_ROOT_CUSTOM,
88+
new JSONObject() {{
89+
put(PAYLOAD_OS_NOTIFICATION_ID, UUID.randomUUID().toString());
90+
}}.toString()
8691
);
8792
}
8893

8994
private static @NonNull Intent helper_basicOSHMSOpenIntentWithActionId(final @NonNull String actionId) throws JSONException {
9095
return helper_baseHMSOpenIntent()
9196
.putExtra(
92-
"custom",
97+
PAYLOAD_OS_ROOT_CUSTOM,
9398
new JSONObject() {{
94-
put("i", UUID.randomUUID().toString());
99+
put(PAYLOAD_OS_NOTIFICATION_ID, UUID.randomUUID().toString());
95100
put(BUNDLE_KEY_ACTION_ID, actionId);
96101
}}.toString()
97102
);
@@ -139,7 +144,6 @@ public void barebonesOSPayload_makesNotificationOpenRequest() throws Exception {
139144
assertNotificationOpenAtIndex(1, UserState.DEVICE_TYPE_HUAWEI);
140145
}
141146

142-
private static final String TEST_ACTION_ID = "myTestActionId";
143147
private static String lastActionId;
144148
@Test
145149
public void firesOSNotificationOpenCallbackWithActionId() throws Exception {
@@ -163,10 +167,10 @@ public void osIAMPreview_showsPreview() throws Exception {
163167

164168
Intent intent = helper_baseHMSOpenIntent()
165169
.putExtra(
166-
"custom",
170+
PAYLOAD_OS_ROOT_CUSTOM,
167171
new JSONObject() {{
168-
put("i", UUID.randomUUID().toString());
169-
put("a", new JSONObject() {{
172+
put(PAYLOAD_OS_NOTIFICATION_ID, UUID.randomUUID().toString());
173+
put(PUSH_ADDITIONAL_DATA_KEY, new JSONObject() {{
170174
put("os_in_app_message_preview_id", "UUID");
171175
}});
172176
}}.toString()

0 commit comments

Comments
 (0)