plotline-engage 4.5.6 → 4.5.8

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.
@@ -39,6 +39,6 @@ repositories {
39
39
 
40
40
  dependencies {
41
41
  implementation 'com.facebook.react:react-native:+'
42
- implementation 'com.gitlab.plotline:plotline-android-sdk:4.1.4'
42
+ implementation 'com.gitlab.plotline:plotline-android-sdk:4.1.5'
43
43
  }
44
44
 
@@ -6,6 +6,8 @@ import android.graphics.RectF;
6
6
  import android.view.View;
7
7
  import android.view.ViewGroup;
8
8
  import android.view.accessibility.AccessibilityNodeInfo;
9
+ import android.content.Context;
10
+ import androidx.annotation.DrawableRes;
9
11
 
10
12
  import androidx.annotation.NonNull;
11
13
 
@@ -29,11 +31,17 @@ import java.util.Map;
29
31
  import so.plotline.insights.Listeners.PlotlineEventsListener;
30
32
  import so.plotline.insights.Listeners.PlotlineRedirectListener;
31
33
  import so.plotline.insights.Plotline;
34
+ import so.plotline.insights.Models.PlotlineNotificationConfig;
35
+ import so.plotline.insights.PlotlinePush;
32
36
 
33
37
  public class RNPlotline extends ReactContextBaseJavaModule {
34
38
 
35
39
  private final ReactApplicationContext reactContext;
36
40
 
41
+ public interface PlotlineReactNativeNotificationClickListener {
42
+ void onNotificationClickedPayloadReceived(JSONObject jsonObject);
43
+ }
44
+
37
45
  public RNPlotline(ReactApplicationContext reactContext) {
38
46
  super(reactContext);
39
47
  this.reactContext = reactContext;
@@ -222,4 +230,37 @@ public class RNPlotline extends ReactContextBaseJavaModule {
222
230
  public void logout() {
223
231
  Plotline.logout();
224
232
  }
233
+
234
+ public static void setNotificationMetadata(Context context, @DrawableRes int smallIcon) {
235
+ PlotlinePush.setPlotlineNotificationMetaData(context, new PlotlineNotificationConfig(smallIcon));
236
+ }
237
+
238
+ @ReactMethod
239
+ public void setToken(String fcmToken) {
240
+ PlotlinePush.setFcmToken(getCurrentActivity(), fcmToken);
241
+ }
242
+
243
+ public static void setFcmToken(Context context, String fcmToken) {
244
+ PlotlinePush.setFcmToken(context, fcmToken);
245
+ }
246
+
247
+ public static boolean isPushPlotline(Map<String, String> remoteMessage) {
248
+ return PlotlinePush.isPushPlotline(remoteMessage);
249
+ }
250
+
251
+ public static void showNotification(Context context, Map<String, String> remoteMessageData) {
252
+ PlotlinePush.showNotification(context, remoteMessageData);
253
+ }
254
+
255
+ public static void setPushNotificationClickListener(PlotlineReactNativeNotificationClickListener plotlineReactNativeNotificationClickListener) {
256
+ PlotlinePush.setPlotlineNotificationClickListener(jsonObject -> {
257
+ if (plotlineReactNativeNotificationClickListener != null) {
258
+ try {
259
+ plotlineReactNativeNotificationClickListener.onNotificationClickedPayloadReceived(jsonObject);
260
+ } catch (Exception e) {
261
+
262
+ }
263
+ }
264
+ });
265
+ }
225
266
  }
package/index.d.ts CHANGED
@@ -17,6 +17,7 @@ declare class plotline {
17
17
  notifyScroll(): void;
18
18
  setPlotlineEventsListener(listener: (eventName: string, properties: {[key: string]: any}) => void): void;
19
19
  setPlotlineRedirectListener(listener: (keyValuePairs: {[key: string]: any}) => void): void;
20
+ setToken(token: string): void;
20
21
  logout(): void;
21
22
  }
22
23
 
package/index.js CHANGED
@@ -175,6 +175,10 @@ class plotline {
175
175
  }
176
176
  RNPlotline.logout();
177
177
  }
178
+
179
+ setToken(token) {
180
+ RNPlotline.setToken(token);
181
+ }
178
182
  }
179
183
 
180
184
  const Plotline = new plotline();
package/ios/RNPlotline.m CHANGED
@@ -93,6 +93,18 @@ RCT_EXPORT_METHOD(logout)
93
93
  [Plotline logout];
94
94
  }
95
95
 
96
+ RCT_EXPORT_METHOD(setToken:(NSString *)token)
97
+ {
98
+ NSMutableData *deviceTokenData = [NSMutableData data];
99
+ for (int i = 0; i < token.length; i += 2) {
100
+ NSString *hexByte = [token substringWithRange:NSMakeRange(i, 2)];
101
+ unsigned int byte;
102
+ [[NSScanner scannerWithString:hexByte] scanHexInt:&byte];
103
+ [deviceTokenData appendBytes:&byte length:1];
104
+ }
105
+ [PlotlinePush setPushTokenWithDeviceToken:deviceTokenData];
106
+ }
107
+
96
108
  RCT_EXPORT_MODULE();
97
109
 
98
110
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotline-engage",
3
- "version": "4.5.6",
3
+ "version": "4.5.8",
4
4
  "description": "React Native plugin for Plotline",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"