How to run codes after the Ionic App has exited? - android

I'm using Ionic 2 to develop my Android project. I need to send a notification while have detected my iBeacon devices nearby even if my App has been exited.
The following plugins does not work for me:
Background mode: Works while App has been put in background. But what I need is to send notifications while the App has been killed.
Bgs: Doesn't work for me. The founder didn't try Ionic 2 project, so that he cannot figure out what may be the problem. But I do create a project here.
Just hope someone can tell me if it's possible to create an independent background service to retrive data. So that I can stop wasting time.

Related

How restart android app after unlock screen

I have a react native app that use paho mqtt (react native module) the problem is that when the screen is lock, this service die. Im not android developer but I read that the problem is that doze mode kill all and my paho service die after a few minutes.
I read this issue https://github.com/eclipse/paho.mqtt.android/issues/226 and test a solution given there but in android > 8 this solution not work anymore.
I think 2 possible solutions:
1. Run service again after unlock the screen (dunno how to do this for
android >8).
2. Restart the app after unlock the screen (Searching for how detect that the screen is unlock in react native).
If someone know how to handle this solutions or another one.
For Android native, you can use Service
A service is simply a component that can run in the background, even when the user is not interacting with your application, so you should create a service only if that is what you need.
I know you are using react-native, but hope the info would provide some hints.

Android background worker

I need to create service for React-Native application that is able to receive push notifications from the server even when the app is closed.
I tried using FCM and it's working great, but I need to make it work without using the third party like FCM.. it needs to be self-hosted service.
I didn't find any package or solution to do so in React-Native so I decided to try to make a native module about that and then add it in my React-Native.
Can anyone tell me where to start - how to create a background listener in Java so it can listen for server requests even if the app is closed?
I am a few months into React-Native and totally new to Native Android development so any kind of advice is appreciated.

Combination of Android service, Cordova background plugin and Skype O365 sdk does not working after few hours while running in background?

I am working on ionic platform and making one Android and iOS application.
Application requirement:
Skype for business O365 login will be there for user and then minimizing the application it will change the status of user like busy, available and note as well on regular interval.
What I have done:
I have used Cordova background mode and Skype websdk.It's logging in fine and setting the status fine while using in foreground.
Problem I am facing:
If I put application in background mode then the status is setting for few minutes but after that somehow it's not setting the status.
So, I am thinking that might be some scenarios:
Might the Android or iOS stopping the background service.
Might the cordova background plugin not working properly.
Might the Skype websdk stops after some time while running in background
Getting this error after the 404 not found code.
https://webpooldb41e02.infra.lync.com/ucwa/oauth/v1/applications/1145363530/me/reportMyActivity
I am researching for the above aspects as well.
I had a same problem. Its not about Background plugin. I found that Skype SDK somehow stops working if it stays in same network for more then around 4800 seconds.
What I did is I signed out and signed Back In user with SetInterval. So token will refreshed and It worked for me. You can use signet and signIn with setInterval of 4000 second or so.

Cordova Push Plugin on Android not working when app is closed or not running

I've been trying to use this plugin for push notification in my app.
https://github.com/phonegap-build/PushPlugin/
And send push by Node-GCM. Everything works perfectly when the app is in foreground and in background (Background = when user tap home button).
The only problem is Notification is not showing when the app is closed or not running. If user close the app by force stop from Setting > Apps or slip the app away to terminate the app task.
I've been finding the solutions for this. But still can't solve this. Is there anyone here having experience of this and can solve it? I didn't change any code of the plugin and following the example client code from Plugin's Github. Please help me solve this. Thank you very much.
Does your notification have a "message"? Like this: {\"message\":\"Hello World!\",\"sound\":\"beep.wav\"}
That was my problem. I figured it out after reading this article: http://community.phonegap.com/nitobi/topics/_pushplugin_background_notifications_dont_seem_to_work
For what I've been reading, there are 3 running modes.
Foreground: when you are using the application.
Background: when you have the application minimized but not closed and you can restore it where you left it before minimizing.
Back-background: when you have closed your application but there are a service generated by the application that is listening some specific events (i.e. waiting push notifications).
When you are in the modes 1 and 2, your application can receive push notifications because the PushPlugin is running but, when you are in mode 3, the plugin will fail because the application is not running, you have to create the service that will be waiting for notifications or what you want.
This is what Whatsapp application is doing for example.
Here you can see a pluggin for AppGyver that does implements a service:
https://github.com/Red-Folder/bgs-core

How to have an android phonegap app allways running

I have an Android app (internal for my company, not public) developed using JQM and Phonegap.
The app check each 15 minutes if the company server have some news for the device (1 device = an employee).
But it only works if the device is not in sleep mode.
I would like at least be able to do the same as whatsapp and other apps, send a little message to the notification area and/or shows a little window, sounds a beep...
I can do some of this (as shows a window, sounds a beep) but only if the device is running in visible (not sleep) mode.
Then my question is:
How to have an android phonegap app that is always running, or at least run each x minutes?
I this is not possible... Is possible then create an "mini" real native app only for this purpose, thus "call" to my app each x minutes?
Thanks,
Guillermo, Spain.
link http://www.tipsfromsiliconvalley.com/2013/07/06/create-a-service-on-android-with-phonegap-application/
There is this article on how to create a service on Android with Phonegap which gives some good information on your problem.
It's using a great plugin in order to build a background service with phonegap easily. But you can't use JS though
I didn't find a way to make JS to run in the Background. BUT you can pass parameters from Java to JS and vice versa with the plugin...which is pretty useful. You would still need to rewrite your JS code in Java though.
you could create a service that calls a javascript callback? For example, you could have a service in Java code that when it receives a text message it calls a javascript callback function to execute some JS code? That would be perfect. plugin that seems to create a service and call Js code:
https://github.com/marknutter/GCM-Cordova

Categories

Resources