cordova-plugin-local-notifications-continued 1.2.4

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.
Files changed (67) hide show
  1. package/.github/FUNDING.yml +1 -0
  2. package/.github/ISSUE_TEMPLATE/report_issue.yml +126 -0
  3. package/CHANGELOG.md +358 -0
  4. package/LICENSE +202 -0
  5. package/README.md +1531 -0
  6. package/images/android-actions-with-input-clicked.png +0 -0
  7. package/images/android-actions-with-input-not-clicked.png +0 -0
  8. package/images/android-actions.png +0 -0
  9. package/images/android-alarms-and-reminders-in-app-settings.png +0 -0
  10. package/images/android-alarms-and-reminders-setting.png +0 -0
  11. package/images/android-app-hibernation-notification.png +0 -0
  12. package/images/android-app-hibernation-settings-android-12.png +0 -0
  13. package/images/android-app-hibernation-settings-android-13-14.png +0 -0
  14. package/images/android-app-hibernation-settings-android-15.png +0 -0
  15. package/images/android-attachments-image-folded.png +0 -0
  16. package/images/android-attachments-image-unfolded.png +0 -0
  17. package/images/android-chat.png +0 -0
  18. package/images/android-icon.svg +19 -0
  19. package/images/android-inbox.png +0 -0
  20. package/images/android-notification-example.png +0 -0
  21. package/images/android-progress.png +0 -0
  22. package/images/android-request-permission.png +0 -0
  23. package/images/android-stack.png +0 -0
  24. package/images/apple-icon.svg +1 -0
  25. package/images/cordova-app-notified-logo.png +0 -0
  26. package/images/ios-actions-with-input.png +0 -0
  27. package/images/ios-actions.png +0 -0
  28. package/images/ios-attachments-image-folded.png +0 -0
  29. package/images/ios-attachments-image-unfolded.png +0 -0
  30. package/images/ios-notification.png +0 -0
  31. package/images/ios-request-permission.png +0 -0
  32. package/images/logo.png +0 -0
  33. package/package.json +53 -0
  34. package/plugin.xml +266 -0
  35. package/src/android/ClickActivity.java +72 -0
  36. package/src/android/LocalNotification.java +779 -0
  37. package/src/android/Manager.java +327 -0
  38. package/src/android/Notification.java +844 -0
  39. package/src/android/Options.java +956 -0
  40. package/src/android/OptionsTrigger.java +104 -0
  41. package/src/android/action/Action.java +214 -0
  42. package/src/android/action/ActionGroup.java +135 -0
  43. package/src/android/build/localnotification.gradle +29 -0
  44. package/src/android/receiver/ClearReceiver.java +61 -0
  45. package/src/android/receiver/RestoreReceiver.java +70 -0
  46. package/src/android/receiver/TriggerReceiver.java +70 -0
  47. package/src/android/trigger/TriggerHandler.java +195 -0
  48. package/src/android/trigger/TriggerHandlerAt.java +63 -0
  49. package/src/android/trigger/TriggerHandlerEvery.java +257 -0
  50. package/src/android/trigger/TriggerHandlerIn.java +69 -0
  51. package/src/android/util/AssetUtil.java +385 -0
  52. package/src/android/util/CallbackContextUtil.java +88 -0
  53. package/src/android/util/PluginFileProvider.java +34 -0
  54. package/src/android/xml/shared_files_provider_paths.xml +38 -0
  55. package/src/ios/APPLocalNotification.h +56 -0
  56. package/src/ios/APPLocalNotification.m +650 -0
  57. package/src/ios/APPNotificationCategory.h +28 -0
  58. package/src/ios/APPNotificationCategory.m +107 -0
  59. package/src/ios/APPNotificationContent.h +32 -0
  60. package/src/ios/APPNotificationContent.m +122 -0
  61. package/src/ios/APPNotificationOptions.h +42 -0
  62. package/src/ios/APPNotificationOptions.m +689 -0
  63. package/src/ios/UNNotificationRequest+APPLocalNotification.h +32 -0
  64. package/src/ios/UNNotificationRequest+APPLocalNotification.m +100 -0
  65. package/src/ios/UNUserNotificationCenter+APPLocalNotification.h +60 -0
  66. package/src/ios/UNUserNotificationCenter+APPLocalNotification.m +344 -0
  67. package/www/local-notification.js +1104 -0
@@ -0,0 +1,385 @@
1
+ /*
2
+ * Apache 2.0 License
3
+ *
4
+ * Copyright (c) Sebastian Katzer 2017
5
+ * Copyright (c) Manuel Beck 2024
6
+ *
7
+ * This file contains Original Code and/or Modifications of Original Code
8
+ * as defined in and that are subject to the Apache License
9
+ * Version 2.0 (the 'License'). You may not use this file except in
10
+ * compliance with the License. Please obtain a copy of the License at
11
+ * http://opensource.org/licenses/Apache-2.0/ and read it before using this
12
+ * file.
13
+ *
14
+ * The Original Code and all software distributed under the License are
15
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19
+ * Please see the License for the specific language governing rights and
20
+ * limitations under the License.
21
+ */
22
+
23
+ package de.appplant.cordova.plugin.localnotification.util;
24
+
25
+ import android.content.ContentResolver;
26
+ import android.content.Context;
27
+ import android.content.res.Resources;
28
+ import androidx.appcompat.content.res.AppCompatResources;
29
+
30
+ import android.graphics.Bitmap;
31
+ import android.graphics.Canvas;
32
+ import android.graphics.Color;
33
+ import android.graphics.BitmapFactory;
34
+ import android.graphics.PorterDuff;
35
+ import android.graphics.PorterDuffXfermode;
36
+ import android.graphics.Rect;
37
+ import android.graphics.RectF;
38
+ import android.graphics.Paint;
39
+ import android.graphics.drawable.BitmapDrawable;
40
+ import android.graphics.drawable.Drawable;
41
+ import android.graphics.drawable.VectorDrawable;
42
+ import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
43
+
44
+ import android.net.Uri;
45
+ import android.util.Log;
46
+
47
+ import java.io.File;
48
+ import java.io.FileNotFoundException;
49
+ import java.io.FileOutputStream;
50
+ import java.io.IOException;
51
+ import java.io.InputStream;
52
+
53
+ /**
54
+ * Util class to map unified asset URIs to native URIs. See {@link AssetUtil#getUri(String, int)}.
55
+ */
56
+ public final class AssetUtil {
57
+
58
+ public static final String TAG = "AssetUtil";
59
+
60
+ /**
61
+ * Needed for access the resources and app directory.
62
+ */
63
+ private final Context context;
64
+
65
+ public static final int RESOURCE_TYPE_DRAWABLE = 0;
66
+ public static final int RESOURCE_TYPE_RAW = 1;
67
+
68
+ public AssetUtil(Context context) {
69
+ this.context = context;
70
+ }
71
+
72
+ /**
73
+ * The Uri for a path.
74
+ * @param path The path to get the Uri for.
75
+ * @param resourceType Only needed, if the path is a res:// path. Represents the type of the resource,
76
+ * can be {@link AssetUtil#RESOURCE_TYPE_DRAWABLE} or {@link AssetUtil#RESOURCE_TYPE_RAW}.
77
+ * @return The Uri for the path or {@link Uri.EMPTY} if the path is empty, does not exists or is not recognizeable.
78
+ */
79
+ public Uri getUri(String path, int resourceType) {
80
+ if (path == null || path.isEmpty()) return Uri.EMPTY;
81
+
82
+ // Resource file from res directory
83
+ if (path.startsWith("res:")) return getUriForResource(path, resourceType);
84
+
85
+ // File from www folder
86
+ if (path.startsWith("www") || path.startsWith("file://")) return getSharedUriForAssetFile(path);
87
+
88
+ // Shared file in the shared_files directory
89
+ if (path.startsWith("shared://")) {
90
+ // Create content:// Uri
91
+ return getSharedUri(new File(getSharedDirectory(), path.replace("shared://", "")));
92
+ }
93
+
94
+ // Path not recognizeable
95
+ Log.e(TAG, "Path not recognizeable: " + path);
96
+ return Uri.EMPTY;
97
+ }
98
+
99
+ /**
100
+ * Gets the Uri for a resource in the res directory.
101
+ * @param resourcePath Path like res://mySound, res://myImage.png, etc.
102
+ * @param resourceType Can be {@link AssetUtil#RESOURCE_TYPE_DRAWABLE} or {@link AssetUtil#RESOURCE_TYPE_RAW}
103
+ * @return {@link Uri.EMPTY} if a resource could not be found.
104
+ */
105
+ public Uri getUriForResource(String resourcePath, int resourceType) {
106
+ // Get from app resources
107
+ Resources resources = context.getResources();
108
+ int resourceId = getResourceId(resources, resourcePath, resourceType);
109
+
110
+ // Get from system resources
111
+ if (resourceId == 0) {
112
+ resources = Resources.getSystem();
113
+ resourceId = getResourceId(resources, resourcePath, resourceType);
114
+ }
115
+
116
+ if (resourceId == 0) {
117
+ Log.w(TAG, "Resource not found: " + resourcePath);
118
+ return Uri.EMPTY;
119
+ }
120
+
121
+ // Will be something like:
122
+ // App Resource: android.resource://com.example.app/raw/mySound
123
+ return new Uri.Builder()
124
+ // Scheme: android.resource
125
+ .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
126
+ // Authority: com.example.app (for the App)
127
+ .authority(resources.getResourcePackageName(resourceId))
128
+ // Resource directory: raw
129
+ .appendPath(resources.getResourceTypeName(resourceId))
130
+ // Resource name: mySound
131
+ .appendPath(resources.getResourceEntryName(resourceId))
132
+ .build();
133
+ }
134
+
135
+ /**
136
+ * Get the resource Id for a given resourceType. Searches in the App resources first, then in the system resources.
137
+ * @param resourceName Can also be a resource path like "res://mySound", "res://myImage.png", etc.
138
+ * @param resourceType Can be {@link AssetUtil#RESOURCE_TYPE_DRAWABLE} or {@link AssetUtil#RESOURCE_TYPE_RAW}
139
+ * @return The resource ID or 0 if not found.
140
+ */
141
+ public int getResourceId(String resourceName, int resourceType) {
142
+ // Get resource from App
143
+ int resourceId = getResourceId(context.getResources(), resourceName, resourceType);
144
+
145
+ // Get resource from system, if not found
146
+ if (resourceId == 0) return getResourceId(Resources.getSystem(), resourceName, resourceType);
147
+
148
+ return resourceId;
149
+ }
150
+
151
+ /**
152
+ * Get the resource Id for a given resourceType.
153
+ * @param resources The resources where to look for, can be {@link Context#getResources()} or {@link Resources#getSystem()}
154
+ * @param resourceName Can also be a resource path like "res://mySound", "res://myImage.png", etc.
155
+ * @param resourceType Can be {@link AssetUtil#RESOURCE_TYPE_DRAWABLE} or {@link AssetUtil#RESOURCE_TYPE_RAW}
156
+ * @return The resource ID or 0 if not found.
157
+ */
158
+ public int getResourceId(Resources resources, String resourceName, int resourceType) {
159
+ if (resourceType == RESOURCE_TYPE_DRAWABLE) {
160
+ // Try first in drawable
161
+ int resourceId = getResourceId(resources, resourceName, "drawable");
162
+
163
+ // Try in mipmap if not found
164
+ if (resourceId == 0) {
165
+ resourceId = getResourceId(resources, resourceName, "mipmap");
166
+ }
167
+
168
+ return resourceId;
169
+
170
+ // Get sound, video, etc.
171
+ } else if (resourceType == RESOURCE_TYPE_RAW) {
172
+ return getResourceId(resources, resourceName, "raw");
173
+ }
174
+
175
+ // Resource type unknown
176
+ Log.e(TAG, "Unknown resource type: " + resourceType);
177
+ return 0;
178
+ }
179
+
180
+ /**
181
+ * Get the resource Id. Searches in a given resource directory and resources.
182
+ * @param resources The resources where to look for, can be {@link Context#getResources()} or {@link Resources#getSystem()}
183
+ * @param resourceName Can also be a resource path like "res://mySound", "res://myImage.png", etc.
184
+ * @param resourceDirectory The directory of the resource, for e.g. "mipmap", "drawable", "raw", etc.
185
+ * @return The resource ID or 0 if not found.
186
+ */
187
+ public int getResourceId(Resources resources, String resourceName, String resourceDirectory) {
188
+ return resources.getIdentifier(getResourceName(resourceName), resourceDirectory, getPackageName(resources));
189
+ }
190
+
191
+ /**
192
+ * Gets the resource name from the path.
193
+ * @param resourcePath Resource path as string.
194
+ */
195
+ public static String getResourceName(String resourcePath) {
196
+ String resourceName = resourcePath;
197
+
198
+ // Get the filename without the path
199
+ if (resourceName.contains("/")) {
200
+ resourceName = resourceName.substring(resourceName.lastIndexOf('/') + 1);
201
+ }
202
+
203
+ // Remove file extension
204
+ if (resourceName.contains(".")) {
205
+ resourceName = resourceName.substring(0, resourceName.lastIndexOf('.'));
206
+ }
207
+
208
+ return resourceName;
209
+ }
210
+
211
+ /**
212
+ * Package name specified by the resource bundle.
213
+ * @return "android" if system resources are used, otherwise the package name of the app.
214
+ */
215
+ private String getPackageName(Resources resources) {
216
+ return resources == Resources.getSystem() ? "android" : context.getPackageName();
217
+ }
218
+
219
+ /**
220
+ * Shared Uri for an asset file.
221
+ * Copies the asset file to the shared directory [App path]/files/shared_files, to make it accessible
222
+ * through a content:// Uri.
223
+ * @param assetPath Path like www/myFile.png or file://myFile.png
224
+ * @return content:// Uri pointing to the shared asset file in [App path]/files/shared_files.
225
+ * E.g. content://com.example.app.localnotifications.provider/shared_files/www/myAssetFile.png
226
+ */
227
+ private Uri getSharedUriForAssetFile(String assetPath) {
228
+ // Change file:// to www folder
229
+ assetPath = assetPath.replaceFirst("file://", "www/");
230
+
231
+ // Create all directories specified by the asset path
232
+ File sharedDirectory = new File(
233
+ getSharedDirectory(),
234
+ // www/my/subfolder
235
+ assetPath.substring(0, assetPath.lastIndexOf('/')));
236
+
237
+ // Create sub directories for the shared directory
238
+ sharedDirectory.mkdirs();
239
+
240
+ // Get the asset file to copy to the shared directory
241
+ String assetFilename = assetPath.substring(assetPath.lastIndexOf('/') + 1);
242
+ File sharedAssetFile = new File(sharedDirectory, assetFilename);
243
+
244
+ try {
245
+ copyFile(context.getAssets().open(assetPath), new FileOutputStream(sharedAssetFile));
246
+ } catch (Exception exception) {
247
+ Log.e(TAG, "File not found: " + assetPath, exception);
248
+ return Uri.EMPTY;
249
+ }
250
+
251
+ return getSharedUri(sharedAssetFile);
252
+ }
253
+
254
+ /**
255
+ * Get the content:// Uri for a shared file.
256
+ * @param sharedFile The file to get the Uri from
257
+ * @return E.g. content://com.example.app.localnotifications.provider/shared_files/mySharedFile.png
258
+ * or Uri.EMPTY if the file is outside the paths supported by the provider.
259
+ */
260
+ private Uri getSharedUri(File sharedFile) {
261
+ try {
262
+ return PluginFileProvider.getUriForFile(context, context.getPackageName() + ".localnotifications.provider", sharedFile);
263
+
264
+ // When the given sharedFile is outside the paths supported by the provider.
265
+ } catch (IllegalArgumentException exception) {
266
+ Log.e(TAG, "sharedFile is outside the paths supported by the provider: " + sharedFile.getAbsolutePath(), exception);
267
+ return Uri.EMPTY;
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Get the shared directory for the app, defined by the file provider paths.
273
+ */
274
+ public File getSharedDirectory() {
275
+ return new File(context.getFilesDir(), "shared_files");
276
+ }
277
+
278
+ /**
279
+ * Get the bitmap for a resource path, which can be e.g. a res://, www or shared:// path.
280
+ * @return The bitmap or null if the resource could not be found, or an {@link IOException} occurred.
281
+ */
282
+ public Bitmap getBitmap(String resourcePath) {
283
+ // Check if uri exists
284
+ Uri resourceUri = getUri(resourcePath, AssetUtil.RESOURCE_TYPE_DRAWABLE);
285
+ if (resourceUri == Uri.EMPTY) return null;
286
+
287
+ // Get bitmap from app resources
288
+ if (resourcePath.startsWith("res://")) {
289
+ return getBitmapFromDrawable(getResourceId(resourcePath, AssetUtil.RESOURCE_TYPE_DRAWABLE));
290
+
291
+ // Get bitmap from file
292
+ } else {
293
+ try {
294
+ return getBitmapFromUri(resourceUri);
295
+ } catch (IOException exception){
296
+ Log.e(TAG, "Could not get bitmap" + resourcePath, exception);
297
+ return null;
298
+ }
299
+ }
300
+ }
301
+ /**
302
+ * Convert Uri to Bitmap.
303
+ */
304
+ public Bitmap getBitmapFromUri(Uri uri) throws IOException {
305
+ return BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));
306
+ }
307
+
308
+ /**
309
+ * Get a bitmap from a drawable resource, which can be a bitmap or vector drawable.
310
+ * @param drawableId
311
+ * @return The bitmap or null if the drawable type is unsupported.
312
+ */
313
+ public Bitmap getBitmapFromDrawable(int drawableId) {
314
+ Drawable drawable = AppCompatResources.getDrawable(context, drawableId);
315
+
316
+ if (drawable instanceof BitmapDrawable) {
317
+ return ((BitmapDrawable) drawable).getBitmap();
318
+
319
+ } else if (drawable instanceof VectorDrawableCompat || drawable instanceof VectorDrawable) {
320
+ Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
321
+ Canvas canvas = new Canvas(bitmap);
322
+ drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
323
+ drawable.draw(canvas);
324
+ return bitmap;
325
+ }
326
+
327
+ Log.e(TAG, "Unsupported drawable type: " + drawable.getClass().getName());
328
+ return null;
329
+ }
330
+
331
+ /**
332
+ * Convert a bitmap to a circular bitmap.
333
+ * This code has been extracted from the Phonegap Plugin Push plugin:
334
+ * https://github.com/phonegap/phonegap-plugin-push
335
+ *
336
+ * @param bitmap Bitmap to convert.
337
+ * @return Circular bitmap.
338
+ */
339
+ public static Bitmap getCircleBitmap(Bitmap bitmap) {
340
+ if (bitmap == null) return null;
341
+
342
+ final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
343
+ final Canvas canvas = new Canvas(output);
344
+ final int color = Color.RED;
345
+ final Paint paint = new Paint();
346
+ final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
347
+ final RectF rectF = new RectF(rect);
348
+
349
+ paint.setAntiAlias(true);
350
+ canvas.drawARGB(0, 0, 0, 0);
351
+ paint.setColor(color);
352
+ float cx = bitmap.getWidth() / 2;
353
+ float cy = bitmap.getHeight() / 2;
354
+ float radius = cx < cy ? cx : cy;
355
+ canvas.drawCircle(cx, cy, radius, paint);
356
+
357
+ paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
358
+ canvas.drawBitmap(bitmap, rect, rect, paint);
359
+
360
+ bitmap.recycle();
361
+
362
+ return output;
363
+ }
364
+
365
+ /**
366
+ * Copy content from input stream into output stream.
367
+ *
368
+ * @param in The input stream.
369
+ * @param out The output stream.
370
+ */
371
+ public static void copyFile(InputStream in, FileOutputStream out) {
372
+ byte[] buffer = new byte[1024];
373
+ int read;
374
+
375
+ try {
376
+ while ((read = in.read(buffer)) != -1) {
377
+ out.write(buffer, 0, read);
378
+ }
379
+ out.flush();
380
+ out.close();
381
+ } catch (Exception e) {
382
+ e.printStackTrace();
383
+ }
384
+ }
385
+ }
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Apache 2.0 License
3
+ *
4
+ * Copyright (c) Sebastian Katzer 2017
5
+ * Copyright (c) Manuel Beck 2025
6
+ *
7
+ * This file contains Original Code and/or Modifications of Original Code
8
+ * as defined in and that are subject to the Apache License
9
+ * Version 2.0 (the 'License'). You may not use this file except in
10
+ * compliance with the License. Please obtain a copy of the License at
11
+ * http://opensource.org/licenses/Apache-2.0/ and read it before using this
12
+ * file.
13
+ *
14
+ * The Original Code and all software distributed under the License are
15
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19
+ * Please see the License for the specific language governing rights and
20
+ * limitations under the License.
21
+ */
22
+
23
+ package de.appplant.cordova.plugin.localnotification.util;
24
+
25
+ import android.util.Log;
26
+ import de.appplant.cordova.plugin.localnotification.Manager;
27
+
28
+ import java.util.HashMap;
29
+
30
+ import org.apache.cordova.CallbackContext;
31
+
32
+ /**
33
+ * Utils class to store and reuse a CallbackContext.
34
+ * Most of the code in this class was copied from the Diagnostic plugin:
35
+ * https://github.com/dpa99c/cordova-diagnostic-plugin
36
+ */
37
+ public final class CallbackContextUtil {
38
+
39
+ private static final String TAG = "CallbackContextUtil";
40
+
41
+ // Map of permission request code to callback context.
42
+ protected static HashMap<Integer, CallbackContext> callbackContexts = new HashMap<Integer, CallbackContext>();
43
+
44
+ /**
45
+ * Constructor
46
+ */
47
+ private CallbackContextUtil() {}
48
+
49
+ /**
50
+ * Gets a callback context for a request code or null if not found.
51
+ * @return CallbackContext or null if not found.
52
+ */
53
+ public static CallbackContext getCallbackContext(int requestCode) {
54
+ CallbackContext callbackContext = callbackContexts.get(requestCode);
55
+
56
+ // Log error, if no context found
57
+ if (callbackContexts == null) {
58
+ Log.e(TAG, "No context found for request code=" + requestCode);
59
+ }
60
+
61
+ return callbackContext;
62
+ }
63
+
64
+ /**
65
+ * Store a {@link CallbackContext} for later retrieval and return a random request code.
66
+ * @return Random request code for the stored context.
67
+ */
68
+ public static int storeContext(CallbackContext callbackContext) {
69
+ return storeContext(callbackContext, Manager.getRandomRequestCode());
70
+ }
71
+
72
+ /**
73
+ * Store a {@link CallbackContext} for later retrieval and return the request code.
74
+ * @return Request code for the stored context.
75
+ */
76
+ public static int storeContext(CallbackContext callbackContext, int requestCode){
77
+ callbackContexts.put(requestCode, callbackContext);
78
+ return requestCode;
79
+ }
80
+
81
+ /**
82
+ * Removes the stored {@link CallbackContext} for a request code.
83
+ */
84
+ public static void clearContext(int requestCode) {
85
+ if (!callbackContexts.containsKey(requestCode)) return;
86
+ callbackContexts.remove(requestCode);
87
+ }
88
+ }
@@ -0,0 +1,34 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+
20
+ package de.appplant.cordova.plugin.localnotification.util;
21
+
22
+ import androidx.core.content.FileProvider;
23
+
24
+ /**
25
+ * FileProvider is a special subclass of ContentProvider that facilitates secure sharing of
26
+ * files associated with an app by creating a content:// Uri for a file instead of a file:/// Uri.
27
+ *
28
+ * It is possible to use FileProvider directly instead of extending it.
29
+ * However, this is not reliable and will causes crashes on some devices.
30
+ */
31
+ public class PluginFileProvider extends FileProvider {
32
+ public PluginFileProvider() {
33
+ }
34
+ }
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <!--
4
+ Licensed to the Apache Software Foundation (ASF) under one
5
+ or more contributor license agreements. See the NOTICE file
6
+ distributed with this work for additional information
7
+ regarding copyright ownership. The ASF licenses this file
8
+ to you under the Apache License, Version 2.0 (the
9
+ "License"); you may not use this file except in compliance
10
+ with the License. You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing,
15
+ software distributed under the License is distributed on an
16
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ KIND, either express or implied. See the License for the
18
+ specific language governing permissions and limitations
19
+ under the License.
20
+ -->
21
+
22
+ <!-- Define the paths for the file provider to share www files and other files -->
23
+ <paths xmlns:android="http://schemas.android.com/apk/res/android">
24
+
25
+ <!--
26
+ files-path: Represents files in the files/ subdirectory of your app's internal storage area.
27
+ This subdirectory is the same as the value returned by Context.getFilesDir().
28
+
29
+ name: A URI path segment. To enforce security, this value hides the name of the subdirectory
30
+ you're sharing. The subdirectory name for this value is contained in the path attribute.
31
+
32
+ path: The subdirectory you're sharing. While the name attribute is a URI path segment,
33
+ the path value is an actual subdirectory name. Notice that the value refers to a
34
+ subdirectory, not an individual file or files. You can't share a single file by its file name,
35
+ nor can you specify a subset of files using wildcards.
36
+ -->
37
+ <files-path name="shared_files" path="shared_files/" />
38
+ </paths>
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Apache 2.0 License
3
+ *
4
+ * Copyright (c) Sebastian Katzer 2017
5
+ *
6
+ * This file contains Original Code and/or Modifications of Original Code
7
+ * as defined in and that are subject to the Apache License
8
+ * Version 2.0 (the 'License'). You may not use this file except in
9
+ * compliance with the License. Please obtain a copy of the License at
10
+ * http://opensource.org/licenses/Apache-2.0/ and read it before using this
11
+ * file.
12
+ *
13
+ * The Original Code and all software distributed under the License are
14
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18
+ * Please see the License for the specific language governing rights and
19
+ * limitations under the License.
20
+ */
21
+
22
+ #import <Cordova/CDVPlugin.h>
23
+
24
+ @import UserNotifications;
25
+
26
+ @interface APPLocalNotification : CDVPlugin <UNUserNotificationCenterDelegate>
27
+
28
+ - (void) launch:(CDVInvokedUrlCommand*)command;
29
+ - (void) ready:(CDVInvokedUrlCommand*)command;
30
+
31
+ - (void) actions:(CDVInvokedUrlCommand*)command;
32
+
33
+ - (void) hasPermission:(CDVInvokedUrlCommand*)command;
34
+ - (void) requestPermission:(CDVInvokedUrlCommand*)command;
35
+
36
+ - (void) schedule:(CDVInvokedUrlCommand*)command;
37
+ - (void) update:(CDVInvokedUrlCommand*)command;
38
+
39
+ - (void) clear:(CDVInvokedUrlCommand*)command;
40
+ - (void) clearAll:(CDVInvokedUrlCommand*)command;
41
+
42
+ - (void) cancel:(CDVInvokedUrlCommand*)command;
43
+ - (void) cancelAll:(CDVInvokedUrlCommand*)command;
44
+
45
+ - (void) type:(CDVInvokedUrlCommand*)command;
46
+
47
+ - (void) ids:(CDVInvokedUrlCommand*)command;
48
+
49
+ - (void) notification:(CDVInvokedUrlCommand*)command;
50
+ - (void) notifications:(CDVInvokedUrlCommand*)command;
51
+
52
+ - (void) openNotificationSettings:(CDVInvokedUrlCommand*)command;
53
+
54
+ - (void) clearBadge:(CDVInvokedUrlCommand*)command;
55
+
56
+ @end