cordova-plugin-mserviceinterface-2.0 1.0.83 → 1.0.85
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
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.
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.85">
|
|
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"/>
|
|
@@ -70,7 +69,6 @@
|
|
|
70
69
|
</provider>
|
|
71
70
|
</config-file>
|
|
72
71
|
<source-file src="src/android/mInterfaceService.java" target-dir="src/com/selfservit/util/" />
|
|
73
|
-
<source-file src="src/android/backgroundNotification.java" target-dir="src/com/selfservit/util/" />
|
|
74
72
|
<source-file src="src/android/mInterfaceReceiver.java" target-dir="src/com/selfservit/util/" />
|
|
75
73
|
<source-file src="src/android/mInterface.java" target-dir="src/com/selfservit/util/" />
|
|
76
74
|
<source-file src="src/android/GeofenceBroadcastReceiver.java" target-dir="src/com/selfservit/util/" />
|
|
@@ -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;
|
|
@@ -195,9 +194,6 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
195
194
|
boolean appInfoUpdated = new mInterfaceUtil().updateAppInfo(args);
|
|
196
195
|
System.out.println("appInfoUpdated: " + appInfoUpdated);
|
|
197
196
|
//if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
198
|
-
if (!isServiceRunning(backgroundNotification.class)) {
|
|
199
|
-
cordova.getActivity().startService(new Intent(cordova.getActivity().getApplicationContext(), backgroundNotification.class));
|
|
200
|
-
}
|
|
201
197
|
if (!isServiceRunning(mInterfaceService.class)) {
|
|
202
198
|
cordova.getActivity().startService(new Intent(cordova.getActivity().getApplicationContext(), mInterfaceService.class));
|
|
203
199
|
} else {
|
|
@@ -237,18 +233,13 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
237
233
|
}
|
|
238
234
|
} else if (action.equals("GetFCMUtils")) {
|
|
239
235
|
try {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
progressObj.put("pushToken", pushToken);
|
|
248
|
-
callbackContext.success(progressObj);
|
|
249
|
-
} else {
|
|
250
|
-
callbackContext.error("Error occurred");
|
|
251
|
-
}
|
|
236
|
+
String userId = OneSignal.getUser().getOnesignalId();
|
|
237
|
+
String pushToken = OneSignal.getUser().getPushSubscription().getToken();
|
|
238
|
+
|
|
239
|
+
JSONObject progressObj = new JSONObject();
|
|
240
|
+
progressObj.put("userId", userId);
|
|
241
|
+
progressObj.put("pushToken", pushToken);
|
|
242
|
+
callbackContext.success(progressObj);
|
|
252
243
|
} catch (Exception e) {
|
|
253
244
|
System.out.println("GetFCMUtils: Exception is: " + e.getMessage());
|
|
254
245
|
callbackContext.error(e.getMessage());
|
package/src/ios/mInterface.m
CHANGED
|
@@ -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
|
-
|
|
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
|
-
}
|