@colorfulcast/capacitor-repro 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CycraftCapacitorRepro.podspec +19 -0
- package/LICENSE +21 -0
- package/README.md +1005 -0
- package/android/build.gradle +63 -0
- package/android/src/main/AndroidManifest.xml +10 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/MessagingService.java +39 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/Repro.java +157 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/ReproHelper.java +142 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/ReproPlugin.java +473 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/events/NotificationActionPerformedEvent.java +26 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/events/NotificationReceivedEvent.java +25 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/events/UrlOpenedEvent.java +22 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/options/GetNewsFeedsOptions.java +35 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/options/SetDateUserProfileOptions.java +39 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/options/SetDoubleUserProfileOptions.java +25 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/options/SetIntegerUserProfileOptions.java +25 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/options/SetLogLevelOptions.java +29 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/options/SetStringUserProfileOptions.java +28 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/options/SetUserIdOptions.java +18 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/options/TrackOptions.java +32 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/options/UpdateNewsFeedsOptions.java +23 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/results/GetDeviceIdResult.java +19 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/results/GetNewsFeedsResult.java +42 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/classes/results/GetUserIdResult.java +23 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/interfaces/EmptyResultCallback.java +5 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/interfaces/Result.java +7 -0
- package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/interfaces/ResultCallback.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +2420 -0
- package/dist/esm/definitions.d.ts +631 -0
- package/dist/esm/definitions.js +50 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +35 -0
- package/dist/esm/web.js +161 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +227 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +230 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Classes/Events/NSNotificationReceivedEvent.swift +18 -0
- package/ios/Plugin/Classes/Events/NotificationActionPerformedEvent.swift +28 -0
- package/ios/Plugin/Classes/Events/UNNotificationReceivedEvent.swift +18 -0
- package/ios/Plugin/Classes/Events/UrlOpenedEvent.swift +16 -0
- package/ios/Plugin/Classes/Options/GetNewsFeedsOptions.swift +31 -0
- package/ios/Plugin/Classes/Options/SetDateUserProfileOptions.swift +21 -0
- package/ios/Plugin/Classes/Options/SetDoubleUserProfileOptions.swift +21 -0
- package/ios/Plugin/Classes/Options/SetIntegerUserProfileOptions.swift +21 -0
- package/ios/Plugin/Classes/Options/SetLogLevelOptions.swift +28 -0
- package/ios/Plugin/Classes/Options/SetStringUserProfileOptions.swift +21 -0
- package/ios/Plugin/Classes/Options/SetUserIdOptions.swift +15 -0
- package/ios/Plugin/Classes/Options/TrackOptions.swift +21 -0
- package/ios/Plugin/Classes/Options/UpdateNewsFeedsOptions.swift +15 -0
- package/ios/Plugin/Classes/Results/GetDeviceIdResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetNewsFeedsResult.swift +40 -0
- package/ios/Plugin/Classes/Results/GetUserIdResult.swift +16 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +6 -0
- package/ios/Plugin/Repro.swift +190 -0
- package/ios/Plugin/ReproConfig.swift +3 -0
- package/ios/Plugin/ReproHelper.swift +77 -0
- package/ios/Plugin/ReproPlugin.h +10 -0
- package/ios/Plugin/ReproPlugin.m +26 -0
- package/ios/Plugin/ReproPlugin.swift +304 -0
- package/package.json +82 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
|
+
reproAndroidVersion = project.hasProperty('reproAndroidVersion') ? rootProject.ext.reproAndroidVersion : '5.17.0'
|
|
7
|
+
firebaseMessagingVersion = project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '23.4.1'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
buildscript {
|
|
11
|
+
repositories {
|
|
12
|
+
google()
|
|
13
|
+
mavenCentral()
|
|
14
|
+
}
|
|
15
|
+
dependencies {
|
|
16
|
+
classpath 'com.android.tools.build:gradle:8.2.1'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
apply plugin: 'com.android.library'
|
|
21
|
+
|
|
22
|
+
android {
|
|
23
|
+
namespace "com.colorfulcasting.capacitorjs.plugins.repro"
|
|
24
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
25
|
+
defaultConfig {
|
|
26
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
27
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
28
|
+
versionCode 1
|
|
29
|
+
versionName "1.0"
|
|
30
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
31
|
+
}
|
|
32
|
+
buildTypes {
|
|
33
|
+
release {
|
|
34
|
+
minifyEnabled false
|
|
35
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
lintOptions {
|
|
39
|
+
abortOnError false
|
|
40
|
+
}
|
|
41
|
+
compileOptions {
|
|
42
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
43
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
repositories {
|
|
48
|
+
google()
|
|
49
|
+
mavenCentral()
|
|
50
|
+
maven { url 'https://cdn.reproio.com/android' }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
dependencies {
|
|
55
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
56
|
+
implementation project(':capacitor-android')
|
|
57
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
58
|
+
implementation "io.repro:repro-android-sdk:$reproAndroidVersion"
|
|
59
|
+
implementation "com.google.firebase:firebase-messaging:$firebaseMessagingVersion"
|
|
60
|
+
testImplementation "junit:junit:$junitVersion"
|
|
61
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
62
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
63
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
<application>
|
|
3
|
+
<service android:name="com.colorfulcasting.capacitorjs.plugins.repro.MessagingService" android:exported="false">
|
|
4
|
+
<intent-filter>
|
|
5
|
+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
6
|
+
</intent-filter>
|
|
7
|
+
</service>
|
|
8
|
+
</application>
|
|
9
|
+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
|
10
|
+
</manifest>
|
package/android/src/main/java/com/colorfulcasting/capacitorjs/plugins/repro/MessagingService.java
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package com.colorfulcasting.capacitorjs.plugins.repro;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.Logger;
|
|
5
|
+
import com.google.firebase.messaging.FirebaseMessagingService;
|
|
6
|
+
import com.google.firebase.messaging.RemoteMessage;
|
|
7
|
+
import java.util.Map;
|
|
8
|
+
|
|
9
|
+
public class MessagingService extends FirebaseMessagingService {
|
|
10
|
+
|
|
11
|
+
@Override
|
|
12
|
+
public void onNewToken(@NonNull String token) {
|
|
13
|
+
super.onNewToken(token);
|
|
14
|
+
io.repro.android.Repro.setPushRegistrationID(token);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
|
|
19
|
+
super.onMessageReceived(remoteMessage);
|
|
20
|
+
Map<String, String> data = remoteMessage.getData();
|
|
21
|
+
|
|
22
|
+
// check whether the application should handle this push notification.
|
|
23
|
+
if (!io.repro.android.Repro.applicationShouldHandlePushNotification(this, data)) {
|
|
24
|
+
Logger.debug(ReproPlugin.TAG, "Ignore push notification: it will be handled by SDK: " + data);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// check whether this push notification is already received.
|
|
29
|
+
if (io.repro.android.Repro.isAlreadyReceivedPushNotification(this, data)) {
|
|
30
|
+
Logger.debug(ReproPlugin.TAG, "Ignore push notification: it is already received: " + data);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// mark this push notification as "received".
|
|
35
|
+
Logger.debug(ReproPlugin.TAG, "Mark push notification as received: " + data);
|
|
36
|
+
io.repro.android.Repro.markPushNotificationReceived(this, data);
|
|
37
|
+
ReproPlugin.onMessageReceived(remoteMessage);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
package com.colorfulcasting.capacitorjs.plugins.repro;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.net.Uri;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
import androidx.annotation.NonNull;
|
|
7
|
+
import androidx.annotation.Nullable;
|
|
8
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.options.GetNewsFeedsOptions;
|
|
9
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.options.SetDateUserProfileOptions;
|
|
10
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.options.SetDoubleUserProfileOptions;
|
|
11
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.options.SetIntegerUserProfileOptions;
|
|
12
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.options.SetLogLevelOptions;
|
|
13
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.options.SetStringUserProfileOptions;
|
|
14
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.options.SetUserIdOptions;
|
|
15
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.options.TrackOptions;
|
|
16
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.options.UpdateNewsFeedsOptions;
|
|
17
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.results.GetDeviceIdResult;
|
|
18
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.results.GetNewsFeedsResult;
|
|
19
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.classes.results.GetUserIdResult;
|
|
20
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.interfaces.EmptyResultCallback;
|
|
21
|
+
import com.colorfulcasting.capacitorjs.plugins.repro.interfaces.NonEmptyResultCallback;
|
|
22
|
+
import com.getcapacitor.Logger;
|
|
23
|
+
import io.repro.android.newsfeed.NewsFeedCampaignType;
|
|
24
|
+
import io.repro.android.newsfeed.NewsFeedEntry;
|
|
25
|
+
import java.util.Arrays;
|
|
26
|
+
import java.util.Date;
|
|
27
|
+
import java.util.HashMap;
|
|
28
|
+
import java.util.List;
|
|
29
|
+
|
|
30
|
+
public class Repro {
|
|
31
|
+
|
|
32
|
+
private ReproPlugin plugin;
|
|
33
|
+
|
|
34
|
+
public Repro(ReproPlugin plugin) {
|
|
35
|
+
this.plugin = plugin;
|
|
36
|
+
io.repro.android.Repro.setOpenUrlCallback(
|
|
37
|
+
new io.repro.android.Repro.OpenUrlCallback() {
|
|
38
|
+
@Override
|
|
39
|
+
public void onOpened(Uri uri) {
|
|
40
|
+
plugin.handleUrlOpened(uri);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public void setup(String token) {
|
|
47
|
+
io.repro.android.Repro.setLogLevel(Log.DEBUG);
|
|
48
|
+
io.repro.android.Repro.setup(plugin.getActivity().getApplication(), token);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void setLogLevel(SetLogLevelOptions options) {
|
|
52
|
+
int logLevel = options.getLogLevel();
|
|
53
|
+
io.repro.android.Repro.setLogLevel(logLevel);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public void setUserId(SetUserIdOptions options) {
|
|
57
|
+
String userId = options.getUserId();
|
|
58
|
+
io.repro.android.Repro.setUserID(userId);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public GetUserIdResult getUserId() {
|
|
62
|
+
String userId = io.repro.android.Repro.getUserID();
|
|
63
|
+
return new GetUserIdResult(userId);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public void setStringUserProfile(SetStringUserProfileOptions options) {
|
|
67
|
+
String key = options.getKey();
|
|
68
|
+
String value = options.getValue();
|
|
69
|
+
|
|
70
|
+
io.repro.android.Repro.setStringUserProfile(key, value);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public void setIntegerUserProfile(SetIntegerUserProfileOptions options) {
|
|
74
|
+
String key = options.getKey();
|
|
75
|
+
Integer value = options.getValue();
|
|
76
|
+
|
|
77
|
+
io.repro.android.Repro.setIntUserProfile(key, value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public void setDoubleUserProfile(SetDoubleUserProfileOptions options) {
|
|
81
|
+
String key = options.getKey();
|
|
82
|
+
Double value = options.getValue();
|
|
83
|
+
|
|
84
|
+
io.repro.android.Repro.setDoubleUserProfile(key, value);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public void setDateUserProfile(SetDateUserProfileOptions options) {
|
|
88
|
+
String key = options.getKey();
|
|
89
|
+
Date value = options.getValue();
|
|
90
|
+
|
|
91
|
+
io.repro.android.Repro.setDateUserProfile(key, value);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public GetDeviceIdResult getDeviceId() {
|
|
95
|
+
String deviceId = io.repro.android.Repro.getDeviceID();
|
|
96
|
+
return new GetDeviceIdResult(deviceId);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public void track(TrackOptions options) {
|
|
100
|
+
String eventName = options.getEventName();
|
|
101
|
+
HashMap<String, Object> eventProperties = options.getEventProperties();
|
|
102
|
+
if (eventProperties == null) {
|
|
103
|
+
io.repro.android.Repro.track(eventName);
|
|
104
|
+
} else {
|
|
105
|
+
io.repro.android.Repro.track(eventName, eventProperties);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public void enablePushNotification() {
|
|
110
|
+
io.repro.android.Repro.enablePushNotification();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public void getNewsFeeds(@NonNull GetNewsFeedsOptions options, @NonNull NonEmptyResultCallback callback) {
|
|
114
|
+
NewsFeedCampaignType campaignType = options.getCampaignType();
|
|
115
|
+
int limit = options.getLimit();
|
|
116
|
+
Long offsetNewsFeedId = options.getOffsetNewsFeedId();
|
|
117
|
+
|
|
118
|
+
new Thread(() -> {
|
|
119
|
+
try {
|
|
120
|
+
List<NewsFeedEntry> newsFeedEntries;
|
|
121
|
+
if (offsetNewsFeedId == null) {
|
|
122
|
+
newsFeedEntries = io.repro.android.Repro.getNewsFeeds(limit, campaignType);
|
|
123
|
+
} else {
|
|
124
|
+
newsFeedEntries = io.repro.android.Repro.getNewsFeeds(limit, offsetNewsFeedId, campaignType);
|
|
125
|
+
}
|
|
126
|
+
GetNewsFeedsResult result = new GetNewsFeedsResult(newsFeedEntries);
|
|
127
|
+
callback.success(result);
|
|
128
|
+
} catch (Exception exception) {
|
|
129
|
+
callback.error(exception);
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
.start();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public void updateNewsFeeds(@NonNull UpdateNewsFeedsOptions options, @NonNull EmptyResultCallback callback) {
|
|
136
|
+
List<NewsFeedEntry> newsFeedEntries = options.getNewsFeedEntries();
|
|
137
|
+
|
|
138
|
+
new Thread(() -> {
|
|
139
|
+
try {
|
|
140
|
+
io.repro.android.Repro.updateNewsFeeds(newsFeedEntries);
|
|
141
|
+
callback.success();
|
|
142
|
+
} catch (Exception exception) {
|
|
143
|
+
callback.error(exception);
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
.start();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public void disableInAppMessagesOnForegroundTransition() {
|
|
150
|
+
io.repro.android.Repro.disableInAppMessagesOnForegroundTransition();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public void enableInAppMessagesOnForegroundTransition() {
|
|
154
|
+
Activity activity = plugin.getActivity();
|
|
155
|
+
io.repro.android.Repro.enableInAppMessagesOnForegroundTransition(activity);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
package com.colorfulcasting.capacitorjs.plugins.repro;
|
|
2
|
+
|
|
3
|
+
import android.net.Uri;
|
|
4
|
+
import android.os.Bundle;
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
import com.getcapacitor.JSArray;
|
|
8
|
+
import com.getcapacitor.JSObject;
|
|
9
|
+
import com.google.firebase.messaging.RemoteMessage;
|
|
10
|
+
import io.repro.android.newsfeed.NewsFeedCampaignType;
|
|
11
|
+
import io.repro.android.newsfeed.NewsFeedEntry;
|
|
12
|
+
import java.util.ArrayList;
|
|
13
|
+
import java.util.HashMap;
|
|
14
|
+
import java.util.Iterator;
|
|
15
|
+
import java.util.List;
|
|
16
|
+
import org.json.JSONException;
|
|
17
|
+
import org.json.JSONObject;
|
|
18
|
+
|
|
19
|
+
public class ReproHelper {
|
|
20
|
+
|
|
21
|
+
@Nullable
|
|
22
|
+
public static HashMap<String, Object> createHashMapFromJSONObject(@Nullable JSONObject object) throws JSONException {
|
|
23
|
+
if (object == null) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
HashMap<String, Object> map = new HashMap<>();
|
|
27
|
+
Iterator<String> keys = object.keys();
|
|
28
|
+
while (keys.hasNext()) {
|
|
29
|
+
String key = keys.next();
|
|
30
|
+
Object value = object.get(key);
|
|
31
|
+
map.put(key, value);
|
|
32
|
+
}
|
|
33
|
+
return map;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public static JSObject createNotificationResult(@NonNull RemoteMessage remoteMessage) {
|
|
37
|
+
JSObject notificationResult = new JSObject();
|
|
38
|
+
notificationResult.put("id", remoteMessage.getMessageId());
|
|
39
|
+
|
|
40
|
+
JSObject data = new JSObject();
|
|
41
|
+
for (String key : remoteMessage.getData().keySet()) {
|
|
42
|
+
Object value = remoteMessage.getData().get(key);
|
|
43
|
+
data.put(key, value);
|
|
44
|
+
}
|
|
45
|
+
notificationResult.put("data", data);
|
|
46
|
+
|
|
47
|
+
RemoteMessage.Notification notification = remoteMessage.getNotification();
|
|
48
|
+
if (notification != null) {
|
|
49
|
+
notificationResult.put("title", notification.getTitle());
|
|
50
|
+
notificationResult.put("body", notification.getBody());
|
|
51
|
+
notificationResult.put("clickAction", notification.getClickAction());
|
|
52
|
+
notificationResult.put("tag", notification.getTag());
|
|
53
|
+
|
|
54
|
+
Uri link = notification.getLink();
|
|
55
|
+
if (link != null) {
|
|
56
|
+
notificationResult.put("link", link.toString());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return notificationResult;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public static JSObject createNotificationResult(@NonNull Bundle bundle) {
|
|
63
|
+
JSObject notificationResult = new JSObject();
|
|
64
|
+
JSObject data = new JSObject();
|
|
65
|
+
for (String key : bundle.keySet()) {
|
|
66
|
+
if (key.equals("google.message_id")) {
|
|
67
|
+
notificationResult.put("id", "" + bundle.get(key).toString());
|
|
68
|
+
} else {
|
|
69
|
+
data.put(key, bundle.get(key));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
notificationResult.put("data", data);
|
|
73
|
+
return notificationResult;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@NonNull
|
|
77
|
+
public static List<NewsFeedEntry> createNewsFeedEntriesFromJSArray(@NonNull JSArray value) throws JSONException {
|
|
78
|
+
List<NewsFeedEntry> newsFeedEntries = new ArrayList<>();
|
|
79
|
+
for (int i = 0; i < value.length(); i++) {
|
|
80
|
+
NewsFeedEntry newsFeedEntry = ReproHelper.createNewsFeedEntryFromJSObject(JSObject.fromJSONObject(value.getJSONObject(i)));
|
|
81
|
+
newsFeedEntries.add(newsFeedEntry);
|
|
82
|
+
}
|
|
83
|
+
return newsFeedEntries;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public static NewsFeedCampaignType convertStringToNewsFeedCampaignType(String type) {
|
|
87
|
+
switch (type) {
|
|
88
|
+
case "ALL" -> {
|
|
89
|
+
return NewsFeedCampaignType.All;
|
|
90
|
+
}
|
|
91
|
+
case "IN_APP_MESSAGE" -> {
|
|
92
|
+
return NewsFeedCampaignType.InAppMessage;
|
|
93
|
+
}
|
|
94
|
+
case "PUSH_NOTIFICATION" -> {
|
|
95
|
+
return NewsFeedCampaignType.PushNotification;
|
|
96
|
+
}
|
|
97
|
+
case "WEB_MESSAGE" -> {
|
|
98
|
+
return NewsFeedCampaignType.WebMessage;
|
|
99
|
+
}
|
|
100
|
+
default -> {
|
|
101
|
+
return NewsFeedCampaignType.Unknown;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public static String convertNewsFeedCampaignTypeToString(NewsFeedCampaignType type) {
|
|
107
|
+
switch (type) {
|
|
108
|
+
case All -> {
|
|
109
|
+
return "ALL";
|
|
110
|
+
}
|
|
111
|
+
case InAppMessage -> {
|
|
112
|
+
return "IN_APP_MESSAGE";
|
|
113
|
+
}
|
|
114
|
+
case PushNotification -> {
|
|
115
|
+
return "PUSH_NOTIFICATION";
|
|
116
|
+
}
|
|
117
|
+
case WebMessage -> {
|
|
118
|
+
return "WEB_MESSAGE";
|
|
119
|
+
}
|
|
120
|
+
default -> {
|
|
121
|
+
return "UNKNOWN";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@NonNull
|
|
127
|
+
private static NewsFeedEntry createNewsFeedEntryFromJSObject(@NonNull JSObject value) throws JSONException {
|
|
128
|
+
JSONObject values = new JSONObject();
|
|
129
|
+
values.put("newsfeed_id", value.getString("id"));
|
|
130
|
+
values.put("campaign_type", value.getString("campaignType"));
|
|
131
|
+
values.put("device_id", value.getString("deviceId"));
|
|
132
|
+
values.put("title", value.getString("title"));
|
|
133
|
+
values.put("summary", value.getString("summary"));
|
|
134
|
+
values.put("body", value.getString("body"));
|
|
135
|
+
values.put("link_url", value.getString("linkUrl"));
|
|
136
|
+
values.put("image_url", value.getString("imageUrl"));
|
|
137
|
+
values.put("delivered_at", value.getString("deliveredAt"));
|
|
138
|
+
values.put("shown", value.getBoolean("shown"));
|
|
139
|
+
values.put("read", value.getBoolean("read"));
|
|
140
|
+
return new NewsFeedEntry(values);
|
|
141
|
+
}
|
|
142
|
+
}
|