I use Ionic 2 and I want to my app do some task when the app is closed. Something like Gmail who continue to notify all the time.
I found this : https://ionicframework.com/docs/v2/native/background-mode/
But I want to create a specific service with specifics method who run in background. This plugin all the application run in background.
Someone can explain me how to do that ?
When people talk about Ionic Framework, they often put it in the “Cordova” or “Angular” buckets, because historically that's what Ionic was: a UI kit for Cordova and Angular apps. That was fine for the first few years of Ionic's life, but up to around 2018 things started changing.
Ionic provides frameworks to use in the application. Whereas Cordova provides plugins to run the application similar to the native app. Ionic provides many different functions, which need to be integrated with the application, whereas Cordova provides the hardware access of a device to the application.
This tutorial will cover an example use case of the Cordova background mode plugin with Ionic 5/Angular (previously Ionic 3). We'll see how you can keep your app running while it's in the background (minimized).
There's been a lot of confusion around how to use Cordova plugins in Ionic 2, and I think a lot of that stems from ngCordova. This was a great little tool that simplified using native plugins in Ionic 1, it can not be used with Ionic 2.
But in a hybrid application like built-in Ionic framework, we have some limitations to do that as the applications are not that flexible to use background services or any broadcasts attached to some working threads. In Ionic, luckily we have a Cordova Plugin, which helps in doing this to some extent.
The way in which you use a non Ionic Native plugin in Ionic 2 is the same as the way you would use it in any Cordova project, which is however the plugin’s documentation says you should use it. However, there are some extra steps you need to take because TypeScript will cause some problems.
I wanted to keep to received notifications when app is closed. I try a solution : Use Push Notification, Firebase for Android and APNS for iOS. This solution works but with 2 problems :
Have to use external services
It can be a little bit hard to configure
I hope this can help. I know I don't explain how we can have a service to run in background ... But that is the solution for my problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With