cordova-plugin-mserviceinterface-2.0 1.0.62 → 1.0.63
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 +1 -1
- package/src/android/backgroundNotification.java +84 -84
- package/src/android/mInterface.java +1416 -1251
- package/src/android/mInterfaceReceiver.java +22 -13
- package/src/android/mInterfaceService.java +45 -37
- package/src/android/mInterfaceUtil.java +60 -33
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.63">
|
|
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>
|
|
@@ -24,95 +24,95 @@ public class backgroundNotification implements OneSignal.OSRemoteNotificationRec
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
String[] baseDirectory;
|
|
27
|
-
File notificationsFile,fileDirectory;
|
|
27
|
+
File notificationsFile, fileDirectory;
|
|
28
28
|
JSONObject msgBody, msgHeader;
|
|
29
|
-
|
|
29
|
+
public static final Locale locale = Locale.US;
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
if (scrID.contains("_chat")) {
|
|
49
|
+
if (!subKey.equals("")) {
|
|
50
|
+
fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "content_store" + "/" + "msvMsg" + "/" + "history" + "/" + packageName + "/" + key + "/" + subKey);
|
|
51
|
+
if (!fileDirectory.exists()) {
|
|
52
|
+
boolean success = fileDirectory.mkdirs();
|
|
53
|
+
if (!success) {
|
|
54
|
+
System.out.println("Directory not created");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
notificationsFile = new File(fileDirectory, subKey + ".txt");
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
60
|
+
// Check if the specified file Exists or not
|
|
61
|
+
if (notificationsFile.exists()) {
|
|
62
|
+
System.out.println("Exists");
|
|
63
|
+
try {
|
|
64
|
+
FileReader fr = new FileReader(notificationsFile);
|
|
65
|
+
BufferedReader bufferedReader = new BufferedReader(fr);
|
|
66
|
+
StringBuilder notificationDatas = new StringBuilder();
|
|
67
|
+
String line;
|
|
68
|
+
while ((line = bufferedReader.readLine()) != null) {
|
|
69
|
+
notificationDatas.append(line);
|
|
70
|
+
System.out.println(line);
|
|
71
|
+
}
|
|
72
|
+
String notificationStr = decrypt(notificationDatas.toString());
|
|
73
|
+
notificationStr = notificationStr + "," + msgBody.toString();
|
|
74
|
+
FileWriter fw = new FileWriter(notificationsFile);
|
|
75
|
+
fw.write(mInterfaceUtil.encrypt(notificationStr));
|
|
76
|
+
fw.close();
|
|
77
|
+
} catch (Exception e) {
|
|
78
|
+
e.printStackTrace();
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
System.out.println("Does not Exists");
|
|
82
|
+
try {
|
|
83
|
+
FileWriter fw = new FileWriter(notificationsFile);
|
|
84
|
+
fw.write(mInterfaceUtil.encrypt("," + notification.getAdditionalData().getString("msgBody")));
|
|
85
|
+
fw.close();
|
|
86
|
+
} catch (IOException | JSONException e1) {
|
|
87
|
+
e1.printStackTrace();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "notifications" + "/" + "unread");
|
|
93
|
+
if (!fileDirectory.exists()) {
|
|
94
|
+
boolean success = fileDirectory.mkdirs();
|
|
95
|
+
if (!success) {
|
|
96
|
+
System.out.println("Directory not created");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
notificationsFile = new File(fileDirectory, notification.getNotificationId() + ".json");
|
|
100
|
+
Date date = new Date();
|
|
101
|
+
msgBody.put("dateTime", Date.parse(date.toString()));
|
|
102
|
+
JSONObject jsonObj = notification.toJSONObject();
|
|
103
|
+
jsonObj.remove("rawPayload");
|
|
104
|
+
FileWriter fw = new FileWriter(notificationsFile);
|
|
105
|
+
fw.write(mInterfaceUtil.encrypt(jsonObj.toString()));
|
|
106
|
+
fw.close();
|
|
107
|
+
}
|
|
108
|
+
} catch (JSONException | IOException e) {
|
|
109
|
+
e.printStackTrace();
|
|
110
|
+
}
|
|
111
|
+
JSONObject data = notification.getAdditionalData();
|
|
112
|
+
Log.i("OneSignalExample", "Received Notification Data: " + data);
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
}
|
|
118
118
|
}
|