mitchhymel / local_notifications

No longer in development -Flutter plugin for creating notifications
BSD 2-Clause "Simplified" License
108 stars 14 forks source link

android manifest issue #15

Closed Rajivrocks-Ltd closed 5 years ago

Rajivrocks-Ltd commented 6 years ago

Hi for a project at school i got the task to add push notifications to our app. i'm a pretty big noob so i was relieved when i saw your app, running it on its own is just fine, but when i try to intergrate it into my app the notifications don't show up and i think i know what the problem is in the manifest you have this line <service android:name="com.mythichelm.localnotifications.services.LocalNotificationsService" android:exported="false" /> for you the entire line is green when i look into your project but in my project the part starting at sercives is red so that includes services. I might be installing it wrong but i moved all the .dart files you had to my lib folder and imported it and when i write code i don't get errors so that went well. but when i press the button the notification just won't show up. could you maybe help me out? I would really appreciate it. image

mitchhymel commented 6 years ago

First, this library is meant for local notifications and doesn't actually support push notifications scenarios. For push notifications, you have to use Firebase Cloud Messaging. There is a flutter plugin for this already.

Second, to talk about how to properly use this library in your app...

The proper way to use a flutter library is the add a reference to it in your project's pubspec. For learning how to use packages in flutter, read the flutter documentation. For learning about pubspec, read the dart documentation.

This is just a guess, but I think the reason your app doesn't work is because you only copied the .dart files from this library, but you actually need some java and swift files for everything to work. Lucky for you, the pubspec manages all of this for you. So you don't need to copy any files, just add a reference the package in your pubspec, and it will pull in all the necessary dart, java, swift files for that plugin to work.

As an example, look at the code for my work-in-progress app that was the motivation for this library:

Thrid, it looks like you are using intellij/Android Studio... There are known issues where these IDEs don't give full support (for example, missing code completion) for the Android project when the flutter project is open as the root gradle project. There is an open issue in the flutter repo to track this. Basically, even if the IDE says there are errors in the Java/Android project, it's likely you will still be able to build and run your flutter app.

Hopefully this helps.

Rajivrocks-Ltd commented 6 years ago

Thank you so much for the detailed reply, I forgot to actually run the project after changing my manifest and adding the plugin in dependencies so it works now. i have another question though if you don't mind.

So in my project we are making a planning app, and we store everything in a local db and we have a due date in the db so what i have to do is to send out a notification 3 days before the due date hits. is this possible with your plugin? or do i need to use the scheduled notification plugins? (there are 2 plugins with this feature i think). I would greatly appreciate a response. I have no clue how i'm gonna do this, maybe you could give me a tip in how to accomplish this if it isn't to much trouble?

Thanks anyways for the reply I really appreciate it.

mitchhymel commented 6 years ago

This plugin doesn't support scheduled notifications. I think you could use android_alarm_manager to run any arbitrary code some time in the future. In your case, you could schedule some function that will use this plugin to create your notification. The downside is that this would only be supported on android. I think background execution like this in iOS is still an unsolved problem for flutter.