cordova-plugin-mserviceinterface-2.0 1.0.42 → 1.0.44
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 +1 -1
- package/plugin.xml +5 -12
- package/src/android/backgroundNotification.java +70 -74
- package/src/android/mInterface.java +4 -0
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
4
|
id="cordova-plugin-mserviceinterface-2.0"
|
|
5
|
-
version="1.0.
|
|
5
|
+
version="1.0.44">
|
|
6
6
|
<name>mserviceinterface-2.0</name>
|
|
7
7
|
<description>This plugin establishes the connection to the native interface and performs the requested task.</description>
|
|
8
8
|
<author>selfservit@gmail.com</author>
|
|
@@ -19,9 +19,8 @@
|
|
|
19
19
|
</js-module>
|
|
20
20
|
<platform name="android">
|
|
21
21
|
<framework src="src/android/doubleogradle.gradle" custom="true" type="gradleReference"/>
|
|
22
|
-
<framework src="com.google.android.gms:play-services:
|
|
23
|
-
|
|
24
|
-
<framework src="com.android.support:support-v4:26.0.1" />
|
|
22
|
+
<framework src="com.google.android.gms:play-services-location:20.0.0" />
|
|
23
|
+
<framework src="com.android.support:support-v4:28.0.0" />
|
|
25
24
|
<framework src="com.google.zxing:core:3.2.1" />
|
|
26
25
|
<framework src="com.journeyapps:zxing-android-embedded:3.2.0@aar" />
|
|
27
26
|
<framework src="id.zelory:compressor:2.1.1" />
|
|
@@ -51,14 +50,8 @@
|
|
|
51
50
|
</config-file>
|
|
52
51
|
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
|
53
52
|
<service android:name="com.selfservit.util.mInterfaceService" android:foregroundServiceType="location" android:enabled="true" android:exported="true"/>
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
android:permission="android.permission.BIND_JOB_SERVICE"
|
|
57
|
-
android:exported="false">
|
|
58
|
-
<intent-filter>
|
|
59
|
-
<action android:name="com.onesignal.NotificationExtender" />
|
|
60
|
-
</intent-filter>
|
|
61
|
-
</service>
|
|
53
|
+
<meta-data android:name="com.onesignal.NotificationServiceExtension"
|
|
54
|
+
android:value="com.selfservit.util.backgroundNotification" />
|
|
62
55
|
<receiver android:name="com.selfservit.util.mInterfaceReceiver" android:enabled="true" android:exported="true">
|
|
63
56
|
<intent-filter>
|
|
64
57
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
package com.selfservit.util;
|
|
2
2
|
|
|
3
|
+
import android.content.Context;
|
|
3
4
|
import android.os.Build;
|
|
4
5
|
import android.os.Environment;
|
|
5
6
|
import android.util.Log;
|
|
6
|
-
import com.onesignal.
|
|
7
|
-
import com.onesignal.
|
|
8
|
-
import com.onesignal.
|
|
7
|
+
import com.onesignal.OSNotification;
|
|
8
|
+
import com.onesignal.OSNotificationReceivedEvent;
|
|
9
|
+
import com.onesignal.OneSignal;
|
|
10
|
+
|
|
9
11
|
import org.json.JSONException;
|
|
10
12
|
import org.json.JSONObject;
|
|
11
13
|
import java.io.BufferedReader;
|
|
@@ -22,90 +24,82 @@ import static com.selfservit.util.mInterfaceUtil.decrypt;
|
|
|
22
24
|
import androidx.annotation.RequiresApi;
|
|
23
25
|
import androidx.core.app.NotificationCompat;
|
|
24
26
|
|
|
25
|
-
public class backgroundNotification
|
|
27
|
+
public class backgroundNotification implements OneSignal.OSRemoteNotificationReceivedHandler {
|
|
28
|
+
|
|
26
29
|
|
|
27
30
|
String[] baseDirectory;
|
|
28
31
|
File notificationsFile,fileDirectory;
|
|
29
32
|
JSONObject msgBody, msgHeader;
|
|
30
33
|
public static final Locale locale = Locale.US;
|
|
31
34
|
|
|
32
|
-
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
33
|
-
@Override
|
|
34
|
-
protected boolean onNotificationProcessing(OSNotificationReceivedResult notification) {
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
@Override
|
|
37
|
+
public void remoteNotificationReceived(Context context, OSNotificationReceivedEvent osNotificationReceivedEvent) {
|
|
38
|
+
/* Do something with notification payload */
|
|
39
|
+
OSNotification notification = osNotificationReceivedEvent.getNotification();
|
|
40
|
+
try {
|
|
41
|
+
msgHeader = (JSONObject) notification.getAdditionalData().get("msgHeader");
|
|
42
|
+
String packageName = msgHeader.getString("appID");
|
|
43
|
+
baseDirectory = packageName.split("\\.");
|
|
44
|
+
String clientID = msgHeader.getString("clientID");
|
|
45
|
+
String countryCode = msgHeader.getString("countryCode");
|
|
46
|
+
msgBody = (JSONObject) notification.getAdditionalData().get("msgBody");
|
|
47
|
+
msgBody.put("notificationID",notification.getNotificationId());
|
|
48
|
+
String scrID = msgBody.getString("scrID");
|
|
49
|
+
String key = msgBody.getString("key");
|
|
50
|
+
String subKey = msgBody.getString("subKey");
|
|
51
|
+
|
|
52
|
+
if(scrID.contains("_chat")) {
|
|
53
|
+
if (!subKey.equals("")) {
|
|
54
|
+
fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "content_store" + "/" + "msvMsg" + "/" + "history"+ "/" + packageName + "/" + key + "/" + subKey);
|
|
55
|
+
if (!fileDirectory.exists()) {
|
|
56
|
+
fileDirectory.mkdirs();
|
|
57
|
+
}
|
|
58
|
+
notificationsFile = new File(fileDirectory, subKey + ".txt");
|
|
44
59
|
|
|
45
|
-
/* Do something with notification payload */
|
|
46
|
-
try {
|
|
47
|
-
msgHeader = (JSONObject) notification.payload.additionalData.get("msgHeader");
|
|
48
|
-
String packageName = msgHeader.getString("appID");
|
|
49
|
-
baseDirectory = packageName.split("\\.");
|
|
50
|
-
String clientID = msgHeader.getString("clientID");
|
|
51
|
-
String countryCode = msgHeader.getString("countryCode");
|
|
52
|
-
msgBody = (JSONObject) notification.payload.additionalData.get("msgBody");
|
|
53
|
-
msgBody.put("notificationID",notification.payload.notificationID);
|
|
54
|
-
String scrID = msgBody.getString("scrID");
|
|
55
|
-
String key = msgBody.getString("key");
|
|
56
|
-
String subKey = msgBody.getString("subKey");
|
|
57
|
-
|
|
58
|
-
if(scrID.contains("_chat")) {
|
|
59
|
-
if (!subKey.equals("")) {
|
|
60
|
-
fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "content_store" + "/" + "msvMsg" + "/" + "history"+ "/" + packageName + "/" + key + "/" + subKey);
|
|
61
|
-
if (!fileDirectory.exists()) {
|
|
62
|
-
fileDirectory.mkdirs();
|
|
63
|
-
}
|
|
64
|
-
notificationsFile = new File(fileDirectory, subKey + ".txt");
|
|
65
|
-
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
// Check if the specified file Exists or not
|
|
62
|
+
if (notificationsFile.exists()) {
|
|
63
|
+
System.out.println("Exists");
|
|
64
|
+
try {
|
|
65
|
+
FileReader fr = new FileReader(notificationsFile);
|
|
66
|
+
BufferedReader bufferedReader = new BufferedReader(fr);
|
|
67
|
+
StringBuilder notificationDatas = new StringBuilder();
|
|
68
|
+
String line;
|
|
69
|
+
while ((line = bufferedReader.readLine()) != null) {
|
|
70
|
+
notificationDatas.append(line);
|
|
71
|
+
System.out.println(line);
|
|
72
|
+
}
|
|
73
|
+
String notificationStr = decrypt(notificationDatas.toString());
|
|
74
|
+
notificationStr = notificationStr + "," +msgBody.toString() ;
|
|
75
|
+
FileWriter fw = new FileWriter(notificationsFile);
|
|
76
|
+
fw.write(mInterfaceUtil.encrypt(notificationStr));
|
|
77
|
+
fw.close();
|
|
78
|
+
} catch (Exception e) {
|
|
79
|
+
System.out.println(e);
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
System.out.println("Does not Exists");
|
|
83
|
+
try {
|
|
84
|
+
FileWriter fw = new FileWriter(notificationsFile);
|
|
85
|
+
fw.write(mInterfaceUtil.encrypt(","+ notification.getAdditionalData().getString("msgBody")));
|
|
86
|
+
fw.close();
|
|
87
|
+
} catch (IOException e1) {
|
|
88
|
+
e1.printStackTrace();
|
|
89
|
+
} catch (JSONException e) {
|
|
90
|
+
e.printStackTrace();
|
|
91
|
+
}
|
|
78
92
|
}
|
|
79
|
-
String notificationStr = decrypt(notificationDatas.toString());
|
|
80
|
-
notificationStr = notificationStr + "," +msgBody.toString() ;
|
|
81
|
-
FileWriter fw = new FileWriter(notificationsFile);
|
|
82
|
-
fw.write(mInterfaceUtil.encrypt(notificationStr));
|
|
83
|
-
fw.close();
|
|
84
|
-
} catch (Exception e) {
|
|
85
|
-
System.out.println(e);
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
88
|
-
System.out.println("Does not Exists");
|
|
89
|
-
try {
|
|
90
|
-
FileWriter fw = new FileWriter(notificationsFile);
|
|
91
|
-
fw.write(mInterfaceUtil.encrypt(","+ notification.payload.additionalData.getString("msgBody")));
|
|
92
|
-
fw.close();
|
|
93
|
-
} catch (IOException e1) {
|
|
94
|
-
e1.printStackTrace();
|
|
95
|
-
} catch (JSONException e) {
|
|
96
|
-
e.printStackTrace();
|
|
97
93
|
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
94
|
} else {
|
|
101
95
|
fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "notifications" + "/" + "unread");
|
|
102
96
|
if (!fileDirectory.exists()) {
|
|
103
97
|
fileDirectory.mkdirs();
|
|
104
98
|
}
|
|
105
|
-
notificationsFile = new File(fileDirectory, notification.
|
|
99
|
+
notificationsFile = new File(fileDirectory, notification.getNotificationId() + ".json");
|
|
106
100
|
Date date = new Date();
|
|
107
101
|
msgBody.put("dateTime",Date.parse(date.toString()));
|
|
108
|
-
JSONObject jsonObj = notification.
|
|
102
|
+
JSONObject jsonObj = notification.toJSONObject();
|
|
109
103
|
jsonObj.remove("rawPayload");
|
|
110
104
|
FileWriter fw = new FileWriter(notificationsFile);
|
|
111
105
|
fw.write(mInterfaceUtil.encrypt(jsonObj.toString()));
|
|
@@ -114,9 +108,11 @@ public class backgroundNotification extends NotificationExtenderService {
|
|
|
114
108
|
} catch (JSONException | IOException e) {
|
|
115
109
|
e.printStackTrace();
|
|
116
110
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
JSONObject data = notification.getAdditionalData();
|
|
112
|
+
Log.i("OneSignalExample", "Received Notification Data: " + data);
|
|
113
|
+
|
|
114
|
+
// If complete isn't call within a time period of 25 seconds, OneSignal internal logic will show the original notification
|
|
115
|
+
// To omit displaying a notification, pass `null` to complete()
|
|
116
|
+
osNotificationReceivedEvent.complete(notification);
|
|
117
|
+
}
|
|
122
118
|
}
|
|
@@ -60,6 +60,7 @@ import com.google.android.gms.location.LocationSettingsStatusCodes;
|
|
|
60
60
|
import com.google.android.gms.tasks.Task;
|
|
61
61
|
import com.google.zxing.integration.android.IntentIntegrator;
|
|
62
62
|
import com.google.zxing.integration.android.IntentResult;
|
|
63
|
+
import com.onesignal.OneSignal;
|
|
63
64
|
|
|
64
65
|
import org.apache.cordova.CallbackContext;
|
|
65
66
|
import org.apache.cordova.CordovaInterface;
|
|
@@ -105,7 +106,10 @@ import id.zelory.compressor.Compressor;
|
|
|
105
106
|
|
|
106
107
|
import static android.app.Activity.RESULT_OK;
|
|
107
108
|
|
|
109
|
+
import androidx.annotation.NonNull;
|
|
110
|
+
import androidx.annotation.Nullable;
|
|
108
111
|
import androidx.annotation.RequiresApi;
|
|
112
|
+
import androidx.core.app.ActivityCompat;
|
|
109
113
|
|
|
110
114
|
public class mInterface extends CordovaPlugin implements com.google.android.gms.location.LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, ResultCallback<LocationSettingsResult> {
|
|
111
115
|
private static final String TAG = "mInterface";
|