diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..723ef36f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/README.md b/README.md index 20f853df4..d912fdf1a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![npm version](https://badge.fury.io/js/de.appplant.cordova.plugin.local-notification.svg)](http://badge.fury.io/js/de.appplant.cordova.plugin.local-notification) -[![PayPayl donate button](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=L3HKQCD9UA35A "Donate once-off to this project using Paypal") +Temporary Fork of Cordova Local-Notification Plugin to fix Android notification led issues and iOS 10 notifications. Cordova Local-Notification Plugin ================================= diff --git a/package.json b/package.json index f4d685d29..64ecea271 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "de.appplant.cordova.plugin.local-notification", + "name": "cordova-plugin-local-notifications-mm", "cordova_name": "Cordova LocalNotification Plugin", - "version": "0.8.4", + "version": "1.0.6", "description": "Schedules and queries for local notifications", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", - "url": "git+https://github.com/katzer/cordova-plugin-local-notifications.git" + "url": "git+https://github.com/dpalou/cordova-plugin-local-notifications.git" }, "keywords": [ "appplant", diff --git a/plugin.xml b/plugin.xml index 250391e0e..0d055a845 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,8 +2,8 @@ + id="cordova-plugin-local-notifications-mm" + version="1.0.6"> LocalNotification diff --git a/src/android/LocalNotification.java b/src/android/LocalNotification.java index b4be09fe9..5dbb735c6 100644 --- a/src/android/LocalNotification.java +++ b/src/android/LocalNotification.java @@ -23,7 +23,7 @@ package de.appplant.cordova.plugin.localnotification; -import android.app.Activity; +import android.os.Build; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaInterface; @@ -34,7 +34,6 @@ import org.json.JSONException; import org.json.JSONObject; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -572,18 +571,8 @@ private static synchronized void sendJavascript(final String js) { eventQueue.add(js); return; } - Runnable jsLoader = new Runnable() { - public void run() { - webView.loadUrl("javascript:" + js); - } - }; - try { - Method post = webView.getClass().getMethod("post",Runnable.class); - post.invoke(webView,jsLoader); - } catch(Exception e) { - ((Activity)(webView.getContext())).runOnUiThread(jsLoader); - } + webView.sendJavascript(js); } /** diff --git a/src/android/notification/AssetUtil.java b/src/android/notification/AssetUtil.java index 66662e557..f3f7bba6a 100644 --- a/src/android/notification/AssetUtil.java +++ b/src/android/notification/AssetUtil.java @@ -322,12 +322,20 @@ int getResIdForDrawable(String resPath) { int getResIdForDrawable(String clsName, String resPath) { String drawable = getBaseName(resPath); int resId = 0; + Class cls; try { - Class cls = Class.forName(clsName + ".R$drawable"); + cls = Class.forName(clsName + ".R$drawable"); resId = (Integer) cls.getDeclaredField(drawable).get(Integer.class); - } catch (Exception ignore) {} + } catch (Exception ignore) { + // Drawable not found, search in mipmap now. + try { + cls = Class.forName(clsName + ".R$mipmap"); + + resId = (Integer) cls.getDeclaredField(drawable).get(Integer.class); + } catch (Exception ignore2) {} + } return resId; } diff --git a/src/android/notification/Notification.java b/src/android/notification/Notification.java index ad363788d..29b80b280 100644 --- a/src/android/notification/Notification.java +++ b/src/android/notification/Notification.java @@ -176,6 +176,10 @@ public void schedule() { context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); if (isRepeating()) { + if (wasInThePast()) { + triggerTime = System.currentTimeMillis(); + } + getAlarmMgr().setRepeating(AlarmManager.RTC_WAKEUP, triggerTime, options.getRepeatInterval(), pi); } else { diff --git a/src/android/notification/Options.java b/src/android/notification/Options.java index e78035958..b98e89dac 100644 --- a/src/android/notification/Options.java +++ b/src/android/notification/Options.java @@ -217,6 +217,10 @@ public Date getTriggerDate() { * Trigger date in milliseconds. */ public long getTriggerTime() { +// return Math.max( +// System.currentTimeMillis(), +// options.optLong("at", 0) * 1000 +// ); return options.optLong("at", 0) * 1000; } diff --git a/src/ios/APPLocalNotification.m b/src/ios/APPLocalNotification.m index 03a2d23e5..f60a73da8 100644 --- a/src/ios/APPLocalNotification.m +++ b/src/ios/APPLocalNotification.m @@ -609,8 +609,9 @@ - (void) didFinishLaunchingWithOptions:(NSNotification*)notification } } +#ifdef __IPHONE_8_0 /** - * Called on otification settings registration is completed. + * Called on notification settings registration is completed. */ - (void) didRegisterUserNotificationSettings:(UIUserNotificationSettings*)settings { @@ -619,6 +620,7 @@ - (void) didRegisterUserNotificationSettings:(UIUserNotificationSettings*)settin _command = NULL; } } +#endif #pragma mark - #pragma mark Life Cycle diff --git a/src/ios/UILocalNotification+APPLocalNotification.m b/src/ios/UILocalNotification+APPLocalNotification.m index 383725389..893f64085 100644 --- a/src/ios/UILocalNotification+APPLocalNotification.m +++ b/src/ios/UILocalNotification+APPLocalNotification.m @@ -61,7 +61,10 @@ - (void) __init self.fireDate = options.fireDate; self.timeZone = [NSTimeZone defaultTimeZone]; self.applicationIconBadgeNumber = options.badgeNumber; - self.repeatInterval = options.repeatInterval; + // required check since iOS 10 + if (NSCalendarUnitEra != options.repeatInterval) { + self.repeatInterval = options.repeatInterval; + } self.alertBody = options.alertBody; self.soundName = options.soundName;