Red-Folder / bgs-core

Core code for the Cordova Background Service
Other
236 stars 105 forks source link

App is failing to access the cordova.plugins.myService? #80

Closed shamun closed 6 years ago

shamun commented 6 years ago

I need to run my app in background using Cordova plugin DOC.

So i tried automatic setup as mentioned in the doc cordova plugin add https://github.com/Red-Folder/bgs-sample.git, but that failed.

Therefore i did the configuration manually (Manual setup of mine is available to download)

Now when i start my app in the mobile, Why myService = cordova.plugins.myService; is not accessible? What might be wrongly implemented?

But because i am not using Plugman logic but manually, what would be the right path and contents of the following files? (just as sample)

a) AndroidManifest.xml:

<service android:name="com.red_folder.phonegap.plugin.backgroundservice.sample.MyService">
   <intent-filter>
      <action android:name="com.red_folder.phonegap.plugin.backgroundservice.sample.MyService" />
   </intent-filter>
</service>

b) in your documentation you have mentioned to do : assets/www/plugins/com.red_folder.phonegap.plugin.backgroundservice.sample/www/myService.js

c) Add following in: res/xml/config.xml

<feature name="BackgroundServicePlugin">
   <param name="android-package" value="com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePlugin" />
</feature>

I have created an empty config.xml file by those lines. (i think i am doing wrong)

d) following section fails in my assets/www/myService.html:

var myService;
function boot() {
  document.addEventListener('deviceready', function() {
    alert("Device ready");
    try {
      myService = cordova.plugins.myService;
    }catch(e) {
      alert(e);
    }
    getStatus();
  }, true);
}
Red-Folder commented 6 years ago

What error did you get when trying to install? Was it similar to the bgs-core problem you had?

I applied same updates to bgs-sample last night. Seemed to be ok when I tried it (although it was only a quick project and run)

shamun commented 6 years ago

YES - similar to the bgs-core problem. Therefore i did manual on both cases. But in both manual case's my myService.html fails myService = cordova.plugins.myService;

I will again retry then from fresh by following the doc : https://github.com/Red-Folder/bgs-core/wiki/Using-the-MyService-Sample which failed for me last night which is why i am doing it manually (i believe my manual config is causing some tiny missing as i am not sure what is the content in res/xml/config.xml)

shamun commented 6 years ago

Excellent. Now its working!! great thanks a lot.

Red-Folder commented 6 years ago

Great. Can this issue now be closed?

shamun commented 6 years ago

Sure. thank you.