danielsogl / awesome-cordova-plugins

Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
https://danielsogl.gitbook.io/awesome-cordova-plugins/
Other
2.41k stars 2.42k forks source link

Local Notifications - Compatibility with new version 0.9 #2113

Closed marcovtwout closed 6 years ago

marcovtwout commented 6 years ago

(issue template did not work here)

Summary This is a heads-up about some changes in the Local Notifications plugin that affects Ionic implementation.

Description The official Ionic Docs has the Local Notifications plugin: https://ionicframework.com/docs/native/local-notifications. It is build against the current release, 0.8.

Recently, the maintainer of the Cordova plugin posted the following notice:

The x branch has been merged into master (30.10.2017)

See the 0.8 branch if you cannot upgrade. Further development for v0.9-beta will happen here. The 0.9-dev and ios10 branches are obsolate and will be removed soon.

Known issues

  • Support for Android Orio is limited yet
  • v0.9 and v0.8 aren't compatible with each other (Wont fix)

Ionic's current requirement of version 0.8 should be documented or fixed in the installation instructions. Otherwise, this will break when 0.9 is released.

The upcoming release 0.9 should include improved support for iOS 11 and Android 8, so it is important that Ionic will also update it's implementation. I asked the maintainer for changelog/upgrade instructions here: https://github.com/katzer/cordova-plugin-local-notifications/issues/1426

ThorvaldAagaard commented 6 years ago

Following instructions on https://ionicframework.com/docs/native/local-notifications/ will now install the new version 0.9-beta.1

Because of the breaking changes where among other things registerPermission is renamed to requestPermission, it is no longer possible to use the ionic wrapper.

Is it possible to upgrade the wrapper to the new version?

himinat commented 6 years ago

not only registerPermission, but a lot of things were changed in new plugin version, including notification fields, etc, so Ionic wrapper really need to upgrade. Do you have some info about time or something?

osvaldoconcepcion commented 6 years ago

+1 for this issue. Ionic Native Wrapper should be updated to be compatible with version 0.9 of this plugin, specially if the command ionic cordova plugin add cordova-plugin-local-notification install that version. Thanks.

borodiliz commented 6 years ago

Same here, update needed. Thanks Ionic team!

marcovtwout commented 6 years ago

As a workaround until we have more info, you can specify the latest stable version like this: ionic cordova plugin add de.appplant.cordova.plugin.local-notification@0.8.5

(The package name "cordova-plugin-local-notification" is only for 0.9)

SimonBrazell commented 6 years ago

The new plugin version appears to be backwards compatible with 0.8, at least for my needs anyway (schedule delayed notifications), working for me on everything except iOS 11 at the moment, exceptions are raised in the Android logs for instance but the notification is still triggered, even on Android 8.

EDIT - Actually disregard, it doesn't completely work, delayed notifications using at are working but repeatable using every don't work. This sucks, my apps in production are broken now for the newer OS with no available fix, even using the latest plugin directly without this wrapper has problems... 👎

marcovtwout commented 6 years ago

@mhartington This commit: https://github.com/ionic-team/ionic-native/commit/50d7762b8a6e3818fad48a8860900d1c1e76ba6b ended up (by accident?) in @ionic-native release 4.5.0, but this breaks all compatibility. I suggest the following short term solution:

This really needs to be fixed, as more and more people will run intro problems when following the official instructions.

Temeteron commented 6 years ago

+1. Same here.

m52go commented 6 years ago

+1.

buttons, priority, and oreo functionality are all missing in versions before 0.9.

anseir commented 6 years ago

+1, it would be nice to have the ionic wrapper working with the 0.9 version

m52go commented 6 years ago

i just added actions?: any; to index.d.ts in node_modules\@ionic-native\local-notifications, and notification action buttons are working fine for me across android 5, 6, 7, and 8. no idea about ios.

if you want access to priority you might have to add a similar line in index.d.ts (priority?: number;) but this field won't work for oreo...for that a work-around is to modify the priority value assigned to the channel variable in createDefaultChannel in Manager.java in plugins\cordova-plugin-local-notification\src\android\notification.

remove & re-add platforms and you should be good to go with notification action buttons and some priority functionality (for android at least).

these are all pretty hack-y hacks but if you REALLY need this functionality, like i did, they might help.

DorianLovera commented 6 years ago

please fix it for other people, I spent my whole weekend trying to figure out what I did wrong...

mixtah commented 6 years ago

@m52go I had been doing the same thing for Android and only a few weeks ago I've been building the IOS version and discovering this issue as well. Since I need to support IOS 11 and I've been using the 0.9 features in Android, I'm putting in some effort modifying all the other files under /node_modules/@ionic_native/local-notifications trying to get "requestPermission" working.

I can manage to get it to build and run "requestPermission" without any issue, however, I don't think anything is happening and I get a crash when attempting to use the 'then' method after.

ERROR: Unhandled Promise rejection: undefined is not an object (evaluating '_this.localNotifications.requestPermission().then') ; Zone: ; Task: Promise.then ; Value: TypeError: undefined is not an object (evaluating '_this.localNotifications.requestPermission().then')

I don't suppose anyone else has made any progress on this?

EDIT: I've managed to fix compatibility (although I don't think I have all the options for schedule) If you overwrite the files in /node_modes/@ionic-native/local-notifications with the files in this .zip file, then you'll be able to use requestPermissions. Modify index.d.ts to add whatever you need to the ILocalNotification interface just as @m52go did, as I only added what I needed for now.

local-notifications.zip

danielsogl commented 6 years ago

I will add the new features with release 5.0 or 4.6.

marcovtwout commented 6 years ago

@danielsogl It's not only about including new features, but also about supporting the current release. Please see my suggestion here which should only take a few minutes to implement: https://github.com/ionic-team/ionic-native/issues/2113#issuecomment-357670810

noelrocha commented 6 years ago

I really need the launch property (it specifies that the app should be launched when the notification arrive) and the actions.

Its only available in the 0.9 version!

+1

ThorvaldAagaard commented 6 years ago

@danielsogl - You closed this about a month ago, and I have just installed (at)ionic-native/local-notifications version 4.7 - As 0.8 and 0.9 are not compatible, what version of https://github.com/katzer/cordova-plugin-local-notifications should I install?

stenioanibal commented 6 years ago

I need to schedule one repeatable local notification to every Friday at 19h.

I using latest version of plugin in ionic but the parameters to repeat notifications is not showed in docs. Parameters like every is a ELocalNotificationTriggerUnit, not string (like Katzer docs or forum's examples). I'm trying create a schedule and repeatable notification in all Fridays of weeks but, this not working because, the comments of plugin files not light my life to perfect understand a method to implement that.

Docs is very obscure in this case.

How i make that? Sorry for my mistake and thanks for your attention.

SimonBrazell commented 6 years ago

Hi @stenioanibal, I had the same issue recently - #2536, I mentioned a workaround in the description if you want to check it out, but basically you just modify the ILocalNotificationTrigger interface and change the type of the every attribute to any so that it will also accept the new parameters for v0.9 of the plugin. Not the best but it works.

stenioanibal commented 6 years ago

@simonbrazell That's most basically and perfect solution to my problem in last days. I test that and works perfect.

One more question aproveitando your time, in my tests, using every with object and passing weekday with current day and a future hour and minute, this not fire a notification, different is case if i use month, day, minute.

The weekday parameter not work to current weekday?

marcovtwout commented 5 years ago

Just checking up on this topic after a while. My solution in https://github.com/ionic-team/ionic-native/issues/2113#issuecomment-357670810 is no longer needed, @danielsogl has been updating @ionic-native/local-notifications since v4.7.0 to support the current 0.9-beta cordova plugin.

matiasbeltramone commented 5 years ago

Hi @stenioanibal, I had the same issue recently - #2536, I mentioned a workaround in the description if you want to check it out, but basically you just modify the ILocalNotificationTrigger interface and change the type of the every attribute to any so that it will also accept the new parameters for v0.9 of the plugin. Not the best but it works.

I try it that but doesn't work :(

I had "@ionic-native/local-notifications": "^4.18.0" and when I use { trigger: { at: Date(), every: 'day' } does not work. Any solution?