javascript - Cordova ibeacon; Send local notification after the app got killed, but does not work on android -


i using cordova / phonegap ibeacon plugin ionicframework @ cordova project. tryin send local notification both on android , ios cordova local notification plugin while entering monitored region , when app killed.

here code :

document.addeventlistener("deviceready", ondeviceready, false);      function diddeterminestateforregion(pluginresult) {     }      function didstartmonitoringforregion (pluginresult) {     }     function didexitregion(pluginresult) {         $cordovalocalnotification.add({         id: 30244234234,         title: "good by!",         text: "hope see again."             }).then(function () {             });     }      function didenterregion (pluginresult) {         $cordovalocalnotification.add({         title: "welcome",         text: "tap launch app"             }).then(function () {              });      };     function didrangebeaconsinregion (pluginresult) {      }      function ondeviceready() {         // safe use device apis         function createbeacon(uuid,nofiystate) {              var uuid = uuid; // mandatory             var identifier = 'estimote'; // mandatory              // throws error if parameters not valid             var beaconregion = new cordova.plugins.locationmanager.beaconregion(identifier, uuid);             beaconregion.notifyentrystateondisplay = true;             return beaconregion;         }         var delegate = new cordova.plugins.locationmanager.delegate();         delegate.diddeterminestateforregion = diddeterminestateforregion;          delegate.didstartmonitoringforregion = didstartmonitoringforregion;          delegate.didrangebeaconsinregion = didrangebeaconsinregion;         delegate.didenterregion = didenterregion;         delegate.didexitregion = didexitregion;          var beaconregion = createbeacon('02681445-8d1b-4f58-99d4-b25f4b129a58',true);         // var beaconregionblue = createbeacon('02681445-8d1b-4f58-99d4-b25f4b129a58',1,,true);         cordova.plugins.locationmanager.setdelegate(delegate);          // required in ios 8+         //cordova.plugins.locationmanager.requestwheninuseauthorization();         cordova.plugins.locationmanager.requestalwaysauthorization();         cordova.plugins.locationmanager.startmonitoringforregion(beaconregion)         .fail(console.error)         .done();      } 

cordova plugins :

com.unarin.cordova.beacon 3.3.0 "proximity beacon plugin" de.appplant.cordova.plugin.local-notification 0.8.1 "localnotification" nl.x-services.plugins.socialsharing 4.3.16 "socialsharing" org.apache.cordova.console 0.2.13 "console" org.apache.cordova.device 0.3.0 "device" 

cordova version : 4.3.0

this works fine ios if app killed on android notifications cames if app in background. when kill app task manager on android never seen local notification.

is possible receive notification on android if app killed ?

thanks help.

lets clear stuff , there states yo confusing :

  1. app service
  2. app running in background (i.e minimized).
  3. app killed (not running @ all)

in cases 3rd state when kill app ( via long press button in custom roms , or force stop app menu in os ) , app removed memory , no code being excuted !

what done in case automatically relaunching service after has been stopped check answer , , can read :

it bad pattern run service forcefully against user's willingness.

there many cordova plugins create broadcastereceiver , simple answer question , if app killed not possible receive notification .

but should consider this: if user kills app , means done intentionally , shouldnt worry if app work or not , user's issue , , not yours developer.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -