cordova-plugin-mserviceinterface-2.0 1.0.103 → 1.0.105
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 +2 -2
- package/plugin.xml +7 -13
- package/src/android/GeofenceBroadcastReceiver.java +20 -103
- package/src/android/doubleogradle.gradle +0 -4
- package/src/android/mInterface.java +667 -365
- package/src/android/mInterfaceService.java +10 -3
- package/src/android/mInterfaceUtil.java +233 -152
- package/src/android/res/layout/activity_camera.xml +12 -0
- package/scripts/mservice-deeplink-setup.js +0 -1182
- package/templates/ios/SceneDelegate.swift +0 -358
- package/www/mServiceAppLink.js +0 -115
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cordova-plugin-mserviceinterface-2.0",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.105",
|
|
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": {
|
|
@@ -25,4 +25,4 @@
|
|
|
25
25
|
"version": ">=5.0.0"
|
|
26
26
|
}
|
|
27
27
|
]
|
|
28
|
-
}
|
|
28
|
+
}
|
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.105">
|
|
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>
|
|
@@ -15,10 +15,6 @@
|
|
|
15
15
|
<js-module src="www/mInterface.js" name="mInterface">
|
|
16
16
|
<clobbers target="mInterface" />
|
|
17
17
|
</js-module>
|
|
18
|
-
<js-module src="www/mServiceAppLink.js" name="mServiceAppLink">
|
|
19
|
-
<runs />
|
|
20
|
-
</js-module>
|
|
21
|
-
<hook type="after_prepare" src="scripts/mservice-deeplink-setup.js" />
|
|
22
18
|
<platform name="android">
|
|
23
19
|
<framework src="src/android/doubleogradle.gradle" custom="true" type="gradleReference"/>
|
|
24
20
|
<framework src="androidx.camera:camera-core:1.5.0" />
|
|
@@ -46,6 +42,7 @@
|
|
|
46
42
|
<config-file target="AndroidManifest.xml" parent="/manifest">
|
|
47
43
|
<uses-feature android:name="android.hardware.camera" android:required="true" />
|
|
48
44
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
45
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
|
|
49
46
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
50
47
|
<uses-permission android:name="android.permission.CAMERA" />
|
|
51
48
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
|
@@ -63,18 +60,14 @@
|
|
|
63
60
|
</queries>
|
|
64
61
|
</config-file>
|
|
65
62
|
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
|
66
|
-
<activity android:name="com.selfservit.util.CameraActivity" android:configChanges="orientation|screenSize" android:screenOrientation="portrait" android:exported="
|
|
67
|
-
<service android:name="com.selfservit.util.mInterfaceService" android:foregroundServiceType="location" android:enabled="true" android:exported="
|
|
68
|
-
<receiver android:name="com.selfservit.util.mInterfaceReceiver" android:enabled="true" android:exported="
|
|
63
|
+
<activity android:name="com.selfservit.util.CameraActivity" android:configChanges="orientation|screenSize" android:screenOrientation="portrait" android:exported="false" android:theme="@style/CameraTheme" />
|
|
64
|
+
<service android:name="com.selfservit.util.mInterfaceService" android:foregroundServiceType="location" android:enabled="true" android:exported="false"/>
|
|
65
|
+
<receiver android:name="com.selfservit.util.mInterfaceReceiver" android:enabled="true" android:exported="false">
|
|
69
66
|
<intent-filter>
|
|
70
67
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
|
71
|
-
<action android:name="com.example.checkservice" />
|
|
72
68
|
</intent-filter>
|
|
73
69
|
</receiver>
|
|
74
|
-
<receiver android:enabled="true" android:exported="
|
|
75
|
-
<intent-filter>
|
|
76
|
-
<action android:name="com.google.android.gms.location.GeofenceEvent" />
|
|
77
|
-
</intent-filter>
|
|
70
|
+
<receiver android:enabled="true" android:exported="false" android:name="com.selfservit.util.GeofenceBroadcastReceiver">
|
|
78
71
|
</receiver>
|
|
79
72
|
<provider android:name="com.selfservit.util.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
|
|
80
73
|
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/opener_paths" />
|
|
@@ -83,6 +76,7 @@
|
|
|
83
76
|
<source-file src="src/android/mInterfaceService.java" target-dir="src/com/selfservit/util/" />
|
|
84
77
|
<source-file src="src/android/mInterfaceReceiver.java" target-dir="src/com/selfservit/util/" />
|
|
85
78
|
<source-file src="src/android/mInterface.java" target-dir="src/com/selfservit/util/" />
|
|
79
|
+
<source-file src="src/android/AttachmentFileIO.java" target-dir="src/com/selfservit/util/" />
|
|
86
80
|
<source-file src="src/android/CameraActivity.java" target-dir="src/com/selfservit/util/" />
|
|
87
81
|
<source-file src="src/android/GeofenceBroadcastReceiver.java" target-dir="src/com/selfservit/util/" />
|
|
88
82
|
<source-file src="src/android/mInterfaceUtil.java" target-dir="src/com/selfservit/util/" />
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
package com.selfservit.util;
|
|
2
2
|
|
|
3
|
-
import android.Manifest;
|
|
4
3
|
import android.app.NotificationChannel;
|
|
5
4
|
import android.app.NotificationManager;
|
|
6
5
|
import android.app.PendingIntent;
|
|
7
6
|
import android.content.BroadcastReceiver;
|
|
8
7
|
import android.content.Context;
|
|
9
8
|
import android.content.Intent;
|
|
10
|
-
import android.content.pm.PackageManager;
|
|
11
9
|
import android.os.Build;
|
|
12
10
|
import android.util.Log;
|
|
13
11
|
import android.widget.Toast;
|
|
14
12
|
import androidx.core.app.NotificationCompat;
|
|
15
13
|
import androidx.core.app.NotificationManagerCompat;
|
|
16
|
-
import androidx.core.content.ContextCompat;
|
|
17
14
|
|
|
18
15
|
import com.google.android.gms.location.Geofence;
|
|
19
16
|
import com.google.android.gms.location.GeofencingEvent;
|
|
@@ -25,7 +22,6 @@ import java.io.FileOutputStream;
|
|
|
25
22
|
import java.io.FileWriter;
|
|
26
23
|
import java.io.IOException;
|
|
27
24
|
import java.io.OutputStreamWriter;
|
|
28
|
-
import java.util.List;
|
|
29
25
|
import java.util.UUID;
|
|
30
26
|
|
|
31
27
|
public class GeofenceBroadcastReceiver extends BroadcastReceiver {
|
|
@@ -35,76 +31,29 @@ public class GeofenceBroadcastReceiver extends BroadcastReceiver {
|
|
|
35
31
|
|
|
36
32
|
@Override
|
|
37
33
|
public void onReceive(Context context, Intent intent) {
|
|
38
|
-
|
|
39
|
-
Log.w(TAG, "Ignoring null geofence intent");
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
GeofencingEvent geofencingEvent;
|
|
43
|
-
String enterMessage;
|
|
44
|
-
String exitMessage;
|
|
45
|
-
try {
|
|
46
|
-
geofencingEvent = GeofencingEvent.fromIntent(intent);
|
|
47
|
-
enterMessage = intent.getStringExtra("enterMessage");
|
|
48
|
-
exitMessage = intent.getStringExtra("exitMessage");
|
|
49
|
-
} catch (RuntimeException e) {
|
|
50
|
-
Log.e(TAG, "Ignoring malformed geofence intent", e);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
34
|
+
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
|
|
53
35
|
|
|
54
|
-
if (geofencingEvent == null) {
|
|
55
|
-
Log.w(TAG, "Ignoring intent without a geofencing event");
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
36
|
if (geofencingEvent.hasError()) {
|
|
59
37
|
Log.e(TAG, "GeofencingEvent error: " + geofencingEvent.getErrorCode());
|
|
60
38
|
return;
|
|
61
39
|
}
|
|
40
|
+
String enterMessage = intent.getStringExtra("enterMessage");
|
|
41
|
+
String exitMessage = intent.getStringExtra("exitMessage");
|
|
62
42
|
int geofenceTransition = geofencingEvent.getGeofenceTransition();
|
|
63
43
|
if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER ||
|
|
64
44
|
geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) {
|
|
65
45
|
String transitionType = geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER ? "enter" : "exit";
|
|
66
|
-
List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences();
|
|
67
|
-
if (triggeringGeofences == null || triggeringGeofences.isEmpty()) {
|
|
68
|
-
Log.w(TAG, "Ignoring event without triggering geofences");
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
46
|
|
|
72
|
-
for (Geofence geofence :
|
|
73
|
-
if (geofence == null) {
|
|
74
|
-
Log.w(TAG, "Ignoring null triggering geofence");
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
47
|
+
for (Geofence geofence : geofencingEvent.getTriggeringGeofences()) {
|
|
77
48
|
String geofenceId = geofence.getRequestId();
|
|
78
|
-
if (!isValidGeofenceId(geofenceId)) {
|
|
79
|
-
Log.w(TAG, "Ignoring geofence with an invalid request ID");
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
49
|
writeEventToJsonFile(context, geofenceId, transitionType);
|
|
50
|
+
createNotificationChannel(context);
|
|
83
51
|
String message = (transitionType.equals("enter") ? enterMessage : exitMessage);
|
|
84
52
|
sendNotification(context, "GeoFence", message);
|
|
85
53
|
// showToast(context, "Geofence " + transitionType + ": " + geofenceId);
|
|
86
54
|
}
|
|
87
55
|
}
|
|
88
56
|
}
|
|
89
|
-
|
|
90
|
-
private static boolean isValidGeofenceId(String geofenceId) {
|
|
91
|
-
if (geofenceId == null) return false;
|
|
92
|
-
String[] parameters = geofenceId.split("--", -1);
|
|
93
|
-
if (parameters.length < 4) return false;
|
|
94
|
-
for (String parameter : parameters) {
|
|
95
|
-
if (parameter.isEmpty() || parameter.equals(".") || parameter.equals("..")) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
for (int i = 0; i < parameter.length(); i++) {
|
|
99
|
-
char character = parameter.charAt(i);
|
|
100
|
-
if (character == '/' || character == '\\' || Character.isISOControl(character)) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
57
|
private void showToast(Context context, String message) {
|
|
109
58
|
//Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_LONG).show();
|
|
110
59
|
}
|
|
@@ -114,23 +63,18 @@ public class GeofenceBroadcastReceiver extends BroadcastReceiver {
|
|
|
114
63
|
JSONObject jsonObject = new JSONObject();
|
|
115
64
|
jsonObject.put("eventName", eventType);
|
|
116
65
|
jsonObject.put("geofenceID", geofenceId);
|
|
117
|
-
String[] parameters = geofenceId.split("--"
|
|
118
|
-
fileDirectory = context.getExternalFilesDir("");
|
|
119
|
-
if (fileDirectory
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
fileDirectory = new File(fileDirectory, "geofence");
|
|
127
|
-
if (!fileDirectory.isDirectory() && !fileDirectory.mkdirs()) {
|
|
128
|
-
throw new IOException("Unable to create geofence event directory");
|
|
129
|
-
}
|
|
66
|
+
String[] parameters = geofenceId.split("--");
|
|
67
|
+
fileDirectory = new File(new File(context.getExternalFilesDir(""), "") + "/" + parameters[0] + "/" + parameters[1] + "/" + parameters[2] + "/" + parameters[3] + "/" + "geofence");
|
|
68
|
+
if (!fileDirectory.exists()) {
|
|
69
|
+
boolean success = fileDirectory.mkdirs();
|
|
70
|
+
if (!success) {
|
|
71
|
+
System.out.println("Directory not created");
|
|
72
|
+
}
|
|
73
|
+
};
|
|
130
74
|
notificationsFile = new File(fileDirectory, geofenceId + "--" + eventType + ".json");
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
75
|
+
FileWriter fw = new FileWriter(notificationsFile);
|
|
76
|
+
fw.write(mInterfaceUtil.encrypt(jsonObject.toString()));
|
|
77
|
+
fw.close();
|
|
134
78
|
Log.i(TAG, "Event written to file: " + geofenceId + ".json");
|
|
135
79
|
} catch (Exception e) {
|
|
136
80
|
Log.e(TAG, "Error writing event to JSON file", e);
|
|
@@ -139,26 +83,6 @@ public class GeofenceBroadcastReceiver extends BroadcastReceiver {
|
|
|
139
83
|
|
|
140
84
|
private void sendNotification(Context context, String title, String message) {
|
|
141
85
|
try {
|
|
142
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
|
|
143
|
-
&& ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS)
|
|
144
|
-
!= PackageManager.PERMISSION_GRANTED) {
|
|
145
|
-
Log.i(TAG, "Skipping geofence notification; notification permission is not granted");
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (!NotificationManagerCompat.from(context).areNotificationsEnabled()) {
|
|
149
|
-
Log.i(TAG, "Skipping geofence notification; notifications are disabled");
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
153
|
-
if (notificationManager == null) return;
|
|
154
|
-
createNotificationChannel(context);
|
|
155
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
156
|
-
NotificationChannel channel = notificationManager.getNotificationChannel(CHANNEL_ID);
|
|
157
|
-
if (channel != null && channel.getImportance() == NotificationManager.IMPORTANCE_NONE) {
|
|
158
|
-
Log.i(TAG, "Skipping geofence notification; notification channel is disabled");
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
86
|
String notification_icon, notification_color, app_name;
|
|
163
87
|
int imageResource,notification_color_id;
|
|
164
88
|
String packageName = context.getPackageName();
|
|
@@ -180,17 +104,12 @@ public class GeofenceBroadcastReceiver extends BroadcastReceiver {
|
|
|
180
104
|
.setAutoCancel(true)
|
|
181
105
|
.setColor(context.getResources().getColor(notification_color_id))
|
|
182
106
|
.setContentIntent(pendingIntent);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
notificationManager.createNotificationChannel(channel);
|
|
186
|
-
}
|
|
107
|
+
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
108
|
+
|
|
187
109
|
int notificationId = UUID.randomUUID().hashCode();
|
|
188
110
|
notificationManager.notify(notificationId, notificationBuilder.build());
|
|
189
111
|
} catch (ClassNotFoundException e) {
|
|
190
|
-
|
|
191
|
-
} catch (RuntimeException e) {
|
|
192
|
-
// Permission or notification settings can change after the checks above.
|
|
193
|
-
Log.e(TAG, "Unable to show geofence notification", e);
|
|
112
|
+
throw new RuntimeException(e);
|
|
194
113
|
}
|
|
195
114
|
}
|
|
196
115
|
|
|
@@ -202,9 +121,7 @@ public class GeofenceBroadcastReceiver extends BroadcastReceiver {
|
|
|
202
121
|
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
|
|
203
122
|
channel.setDescription(description);
|
|
204
123
|
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
|
|
205
|
-
|
|
206
|
-
notificationManager.createNotificationChannel(channel);
|
|
207
|
-
}
|
|
124
|
+
notificationManager.createNotificationChannel(channel);
|
|
208
125
|
}
|
|
209
126
|
}
|
|
210
127
|
}
|