cordova-plugin-mserviceinterface-2.0 1.0.83 → 1.0.84

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-mserviceinterface-2.0",
3
- "version": "1.0.83",
3
+ "version": "1.0.84",
4
4
  "description": "This plugin establishes the connection to the native interface and performs the requested task.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/plugin.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
- xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.83">
3
+ xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.84">
4
4
  <name>mserviceinterface-2.0</name>
5
5
  <description>This plugin establishes the connection to the native interface and performs the requested task.</description>
6
6
  <author>selfservit@gmail.com</author>
@@ -53,7 +53,6 @@
53
53
  </config-file>
54
54
  <config-file target="AndroidManifest.xml" parent="/manifest/application">
55
55
  <service android:name="com.selfservit.util.mInterfaceService" android:foregroundServiceType="location" android:enabled="true" android:exported="true"/>
56
- <meta-data android:name="com.onesignal.NotificationServiceExtension" android:value="com.selfservit.util.backgroundNotification" />
57
56
  <receiver android:name="com.selfservit.util.mInterfaceReceiver" android:enabled="true" android:exported="true">
58
57
  <intent-filter>
59
58
  <action android:name="android.intent.action.BOOT_COMPLETED"/>
@@ -69,7 +69,6 @@ import com.google.android.gms.location.LocationSettingsStatusCodes;
69
69
  import com.google.android.gms.location.Priority;
70
70
  import com.google.zxing.integration.android.IntentIntegrator;
71
71
  import com.google.zxing.integration.android.IntentResult;
72
- import com.onesignal.OSDeviceState;
73
72
  import com.onesignal.OneSignal;
74
73
 
75
74
  import org.apache.cordova.CallbackContext;
@@ -237,18 +236,13 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
237
236
  }
238
237
  } else if (action.equals("GetFCMUtils")) {
239
238
  try {
240
- OSDeviceState device = OneSignal.getDeviceState();
241
- if (device != null) {
242
- String userId = device.getUserId();
243
- //Get device's push token identifier
244
- String pushToken = device.getPushToken();
245
- JSONObject progressObj = new JSONObject();
246
- progressObj.put("userId", userId);
247
- progressObj.put("pushToken", pushToken);
248
- callbackContext.success(progressObj);
249
- } else {
250
- callbackContext.error("Error occurred");
251
- }
239
+ String userId = OneSignal.getUser().getOnesignalId();
240
+ String pushToken = OneSignal.getUser().getPushSubscription().getToken();
241
+
242
+ JSONObject progressObj = new JSONObject();
243
+ progressObj.put("userId", userId);
244
+ progressObj.put("pushToken", pushToken);
245
+ callbackContext.success(progressObj);
252
246
  } catch (Exception e) {
253
247
  System.out.println("GetFCMUtils: Exception is: " + e.getMessage());
254
248
  callbackContext.error(e.getMessage());
@@ -11,7 +11,6 @@
11
11
  #include <sys/sysctl.h>
12
12
  #include "TargetConditionals.h"
13
13
  #import "OneSignalPush.h"
14
- #import <OneSignal/OneSignal.h>
15
14
  #import <objc/runtime.h>
16
15
  #import <AVFoundation/AVFoundation.h>
17
16
  #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
@@ -344,11 +343,7 @@
344
343
 
345
344
  }
346
345
  - (void)GetFCMUtils:(CDVInvokedUrlCommand *)command {
347
- OSDeviceState *deviceState = [OneSignal getDeviceState];
348
- NSMutableDictionary * deviceDict = [[NSMutableDictionary alloc] init];
349
- [deviceDict setValue:deviceState.userId forKey:@"userId"];
350
- [deviceDict setValue:deviceState.pushToken forKey:@"pushToken"];
351
- CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceDict];
346
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES];
352
347
  [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
353
348
  }
354
349
 
@@ -1,75 +0,0 @@
1
- package com.selfservit.util;
2
-
3
- import static com.selfservit.util.mInterfaceUtil.decrypt;
4
-
5
- import android.content.Context;
6
- import android.util.Log;
7
-
8
- import com.onesignal.OSNotification;
9
- import com.onesignal.OSNotificationReceivedEvent;
10
- import com.onesignal.OneSignal;
11
-
12
- import org.json.JSONException;
13
- import org.json.JSONObject;
14
-
15
- import java.io.BufferedReader;
16
- import java.io.File;
17
- import java.io.FileReader;
18
- import java.io.FileWriter;
19
- import java.io.IOException;
20
- import java.util.Date;
21
- import java.util.Locale;
22
-
23
- public class backgroundNotification implements OneSignal.OSRemoteNotificationReceivedHandler {
24
-
25
-
26
- String[] baseDirectory;
27
- File notificationsFile, fileDirectory;
28
- JSONObject msgBody, msgHeader;
29
- public static final Locale locale = Locale.US;
30
-
31
-
32
- @Override
33
- public void remoteNotificationReceived(Context context, OSNotificationReceivedEvent osNotificationReceivedEvent) {
34
- /* Do something with notification payload */
35
- OSNotification notification = osNotificationReceivedEvent.getNotification();
36
- try {
37
- msgHeader = (JSONObject) notification.getAdditionalData().get("msgHeader");
38
- String packageName = msgHeader.getString("appID");
39
- baseDirectory = packageName.split("\\.");
40
- String clientID = msgHeader.getString("clientID");
41
- String countryCode = msgHeader.getString("countryCode");
42
- msgBody = (JSONObject) notification.getAdditionalData().get("msgBody");
43
- msgBody.put("notificationID", notification.getNotificationId());
44
- String scrID = msgBody.getString("scrID");
45
- String key = msgBody.getString("key");
46
- String subKey = msgBody.getString("subKey");
47
-
48
- if (!scrID.contains("_chat")) {
49
- fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "notifications" + "/" + "unread");
50
- if (!fileDirectory.exists()) {
51
- boolean success = fileDirectory.mkdirs();
52
- if (!success) {
53
- System.out.println("Directory not created");
54
- }
55
- }
56
- notificationsFile = new File(fileDirectory, notification.getNotificationId() + ".json");
57
- Date date = new Date();
58
- msgBody.put("dateTime", Date.parse(date.toString()));
59
- JSONObject jsonObj = notification.toJSONObject();
60
- jsonObj.remove("rawPayload");
61
- FileWriter fw = new FileWriter(notificationsFile);
62
- fw.write(mInterfaceUtil.encrypt(jsonObj.toString()));
63
- fw.close();
64
- }
65
- } catch (JSONException | IOException e) {
66
- e.printStackTrace();
67
- }
68
- JSONObject data = notification.getAdditionalData();
69
- Log.i("OneSignalExample", "Received Notification Data: " + data);
70
-
71
- // If complete isn't call within a time period of 25 seconds, OneSignal internal logic will show the original notification
72
- // To omit displaying a notification, pass `null` to complete()
73
- osNotificationReceivedEvent.complete(notification);
74
- }
75
- }