react-native-mapp-plugin 1.0.11-beta15 → 1.0.11-beta16

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/Mapp.js CHANGED
@@ -52,8 +52,8 @@ export class Mapp {
52
52
  *
53
53
  * @param token
54
54
  */
55
- static setToken(token: string) {
56
- RNMappPluginModule.setToken(token);
55
+ static setToken(token: string): Promise<Boolean> {
56
+ return RNMappPluginModule.setToken(token);
57
57
  }
58
58
 
59
59
  /**
@@ -70,7 +70,7 @@ export class Mapp {
70
70
  * @param {remoteMessage} push message received
71
71
  */
72
72
  static setRemoteMessage(remoteMessage: Any) {
73
- RNMappPluginModule.setRemoteMessage(JSON.stringify(remoteMessage));
73
+ return RNMappPluginModule.setRemoteMessage(JSON.stringify(remoteMessage));
74
74
  }
75
75
 
76
76
  /**
@@ -87,8 +87,8 @@ export class Mapp {
87
87
  *
88
88
  * @param alias
89
89
  */
90
- static setAlias(alias: string) {
91
- RNMappPluginModule.setAlias(alias);
90
+ static setAlias(alias: string): Promise<Boolean> {
91
+ return RNMappPluginModule.setAlias(alias);
92
92
  }
93
93
 
94
94
  /**
@@ -280,6 +280,10 @@ export class Mapp {
280
280
  return RNMappPluginModule.removeBadgeNumber();
281
281
  }
282
282
 
283
+ static requestGeofenceLocationPermission(): Promise<boolean> {
284
+ return RNMappPluginModule.requestGeofenceLocationPermission();
285
+ }
286
+
283
287
  static startGeofencing(): Promise<string> {
284
288
  return RNMappPluginModule.startGeofencing();
285
289
  }
@@ -47,6 +47,7 @@ import com.google.firebase.messaging.RemoteMessage;
47
47
  import org.json.JSONException;
48
48
  import org.json.JSONObject;
49
49
 
50
+ import java.util.ArrayList;
50
51
  import java.util.Iterator;
51
52
  import java.util.List;
52
53
  import java.util.Map;
@@ -112,9 +113,50 @@ public class RNMappPluginModule extends ReactContextBaseJavaModule {
112
113
  }
113
114
 
114
115
  @ReactMethod
115
- public void requestPostNotificationPermission(Promise promise){
116
+ public void requestGeofenceLocationPermission(Promise promise) {
117
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M && getCurrentActivity() instanceof ReactActivity) {
118
+ ReactActivity activity = (ReactActivity) getCurrentActivity();
119
+ boolean fineLoc = activity.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
120
+ boolean backLoc = activity.checkSelfPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED;
121
+ boolean coarseLoc = activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
122
+ boolean geofencePermission = false;
123
+ List<String> requiredPermissions = new ArrayList<>();
124
+ requiredPermissions.addAll(List.of(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION));
125
+
126
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
127
+ geofencePermission = fineLoc;
128
+ } else {
129
+ geofencePermission = fineLoc && backLoc;
130
+ }
131
+
132
+
133
+ if (!geofencePermission) {
134
+ activity.requestPermissions(requiredPermissions.toArray(new String[]{}), 1,
135
+ (requestCode, permissions, results) -> {
136
+ for (int i : results) {
137
+ if (i != PackageManager.PERMISSION_GRANTED) {
138
+ //Toast.makeText(activity, "PERMISSION NOT GRANTED", Toast.LENGTH_SHORT).show();
139
+ promise.resolve(false);
140
+ return false;
141
+ }
142
+ }
143
+ //Toast.makeText(activity, "PERMISSION GRANTED", Toast.LENGTH_SHORT).show();
144
+ promise.resolve(true);
145
+ return true;
146
+ });
147
+ } else {
148
+ //Toast.makeText(activity, "PERMISSION ALREADY GRANTED", Toast.LENGTH_SHORT).show();
149
+ promise.resolve(true);
150
+ }
151
+ } else {
152
+ promise.reject("Can't access activity for requesting permission!");
153
+ }
154
+ }
155
+
156
+ @ReactMethod
157
+ public void requestPostNotificationPermission(Promise promise) {
116
158
  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S_V2 && getCurrentActivity() instanceof ReactActivity) {
117
- ReactActivity activity= (ReactActivity) getCurrentActivity();
159
+ ReactActivity activity = (ReactActivity) getCurrentActivity();
118
160
  if (activity.checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
119
161
  activity.requestPermissions(new String[]{Manifest.permission.POST_NOTIFICATIONS}, 1,
120
162
  (requestCode, permissions, results) -> {
@@ -133,17 +175,19 @@ public class RNMappPluginModule extends ReactContextBaseJavaModule {
133
175
  //Toast.makeText(activity, "PERMISSION ALREADY GRANTED", Toast.LENGTH_SHORT).show();
134
176
  promise.resolve(true);
135
177
  }
136
- }else{
178
+ } else {
137
179
  promise.reject("Can't access activity for requesting permission!");
138
180
  }
139
181
  }
140
182
 
141
183
  @ReactMethod
142
- public void setRemoteMessage(String msgJson) {
184
+ public void setRemoteMessage(String msgJson, Promise promise) {
143
185
  RemoteMessage remoteMessage = getRemoteMessage(msgJson);
144
186
  if (remoteMessage != null) {
145
187
  Appoxee.instance().setRemoteMessage(remoteMessage);
188
+ promise.resolve(true);
146
189
  }
190
+ promise.resolve(false);
147
191
  }
148
192
 
149
193
  @ReactMethod
@@ -158,8 +202,9 @@ public class RNMappPluginModule extends ReactContextBaseJavaModule {
158
202
  }
159
203
 
160
204
  @ReactMethod
161
- public void setToken(String token) {
205
+ public void setToken(String token, Promise promise) {
162
206
  Appoxee.instance().setToken(token);
207
+ promise.resolve(true);
163
208
  }
164
209
 
165
210
  @ReactMethod
@@ -173,14 +218,14 @@ public class RNMappPluginModule extends ReactContextBaseJavaModule {
173
218
  }
174
219
 
175
220
  @ReactMethod
176
- public void setAlias(String alias) {
221
+ public void setAlias(String alias, Promise promise) {
177
222
  Appoxee.instance().setAlias(alias);
223
+ promise.resolve(true);
178
224
  }
179
225
 
180
226
  @ReactMethod
181
227
  public void engage2() {
182
228
  Appoxee.engage(Objects.requireNonNull(application));
183
-
184
229
  }
185
230
 
186
231
  @ReactMethod
@@ -212,7 +257,7 @@ public class RNMappPluginModule extends ReactContextBaseJavaModule {
212
257
 
213
258
  @ReactMethod
214
259
  public void engageTestServer(String cepURl, String sdkKey, String googleProjectId, String server, String appID,
215
- String tenantID) {
260
+ String tenantID) {
216
261
  AppoxeeOptions opt = new AppoxeeOptions();
217
262
  opt.appID = appID;
218
263
  opt.sdkKey = sdkKey;
@@ -414,8 +459,8 @@ public class RNMappPluginModule extends ReactContextBaseJavaModule {
414
459
 
415
460
  @ReactMethod
416
461
  public void triggerStatistic(Integer templateId, String originalEventId,
417
- String trackingKey, Long displayMillis,
418
- String reason, String link) {
462
+ String trackingKey, Long displayMillis,
463
+ String reason, String link) {
419
464
  Appoxee.instance()
420
465
  .triggerStatistcs((reactContext.getApplicationContext()), getInAppStatisticsRequestObject(templateId,
421
466
  originalEventId, trackingKey, displayMillis, reason, link));
@@ -448,22 +493,22 @@ public class RNMappPluginModule extends ReactContextBaseJavaModule {
448
493
  }
449
494
 
450
495
  @ReactMethod
451
- public void getDeviceDmcInfo(final Promise promise){
496
+ public void getDeviceDmcInfo(final Promise promise) {
452
497
  try {
453
- Map<String, String> map= Appoxee.instance().getDmcDeviceInfo();
454
- WritableMap wm=new WritableNativeMap();
455
- for(Map.Entry<String, String> item : map.entrySet()){
456
- wm.putString(item.getKey(),item.getValue());
498
+ Map<String, String> map = Appoxee.instance().getDmcDeviceInfo();
499
+ WritableMap wm = new WritableNativeMap();
500
+ for (Map.Entry<String, String> item : map.entrySet()) {
501
+ wm.putString(item.getKey(), item.getValue());
457
502
  }
458
503
  promise.resolve(wm);
459
504
  } catch (Exception e) {
460
- promise.reject("Error getting DMC Info",e);
505
+ promise.reject("Error getting DMC Info", e);
461
506
  }
462
507
  }
463
508
 
464
509
  private static InAppStatistics getInAppStatisticsRequestObject(int templateId, String originalEventId,
465
- String trackingKey, Long displayMillis,
466
- String reason, String link) {
510
+ String trackingKey, Long displayMillis,
511
+ String reason, String link) {
467
512
 
468
513
  InAppStatistics inAppStatistics = new InAppStatistics();
469
514
  // This will be received from the respective Screens.
@@ -591,7 +636,7 @@ public class RNMappPluginModule extends ReactContextBaseJavaModule {
591
636
  .setCollapseKey(collapseKey);
592
637
 
593
638
  if (data != null) {
594
- for (Iterator<String> it = data.keys(); it.hasNext();) {
639
+ for (Iterator<String> it = data.keys(); it.hasNext(); ) {
595
640
  String k = it.next();
596
641
  builder.addData(k, data.getString(k));
597
642
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mapp-plugin",
3
- "version": "1.0.11-beta15",
3
+ "version": "1.0.11-beta16",
4
4
  "description": "Mapp SDK for React Native.",
5
5
  "main": "index.js",
6
6
  "keywords": [