You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Erik Jan de Wit <ed...@redhat.com> on 2014/02/21 11:53:19 UTC

CB-4846

Hi,

I’ve created an initial version for https://issues.apache.org/jira/browse/CB-4846 the plugin is located at https://github.com/edewit/cordova-background-plugin

Cheers,
	Erik Jan

Re: CB-4846

Posted by Erik Jan de Wit <ed...@redhat.com>.
> This sounds to me like somehow the callbackIDs are out of sync. missing a
> keepCallback?

Right that was it, I thought it had something to do with it being in the background but it was a simple mistake.

Fixed it now looks much nicer



Re: CB-4846

Posted by Jesse <pu...@gmail.com>.
This sounds to me like somehow the callbackIDs are out of sync. missing a
keepCallback?
... is there a window.onerror js handler to see what is actually happening?

@purplecabbage
risingj.com


On Tue, Feb 25, 2014 at 12:19 AM, Shazron <sh...@gmail.com> wrote:

> That is odd, if calling into JavaScript from being in the background works,
> the pluginResult method should work as well. Might be worth investigating
>
>
> On Tue, Feb 25, 2014 at 12:05 AM, Erik Jan de Wit <ed...@redhat.com>
> wrote:
>
> > Hi Shazron,
> >
> > Actually I started out building it this way, I've changed it to way it's
> > now, because it didn't work. Once the application has moved to the
> > background trying to invoke the method with the plugin result no longer
> > works. I've seen other plugins use the 'named' callback 'trick' and
> thought
> > that was the way to invoke a callback from background. Shall I try to
> > investigate why this is not working?
> >
> > Cheers,
> >         Erik Jan
> >
> > On 24 Feb,2014, at 19:36 , Shazron <sh...@gmail.com> wrote:
> >
> > > Hi Erik,
> > > The gist of it is here:
> > >
> >
> http://cordova.apache.org/docs/en/3.4.0/guide_platforms_ios_plugin.md.html#iOS%20Plugins
> > >
> > > Basically, you have to modify your js interface to take in a success
> and
> > > failure callback. Then, in native code you create a PluginResult and
> set
> > it
> > > to a specific command status (CDVCommandStatus_*), then send it back
> > > through the commandDelegate - it will figure out how to route it
> > properly.
> > > There are examples in the link above.
> > >
> > >
> > > On Sun, Feb 23, 2014 at 11:38 PM, Erik Jan de Wit <ed...@redhat.com>
> > wrote:
> > >
> > >>
> > >> On 22 Feb,2014, at 0:01 , Shazron <sh...@gmail.com> wrote:
> > >>
> > >>> Joe - this calls a background fetch handler for your app at an
> > interval,
> > >> it
> > >>> doesn't really run in the background.
> > >>>
> > >>> Erik - just a quick code review:
> > >>> 1. The method swizzling stuff is great but what I have planned
> > (sometime
> > >> in
> > >>> the future, in progress) is this:
> > >>> https://issues.apache.org/jira/browse/CB-5601
> > >>
> > >> Ahh cool, I'll keep an eye on that one.
> > >>
> > >>> 2. The way you are using callbacks is not quite correct
> > >>
> > >> Could you elaborate on that, I'll be more then happy to fix it
> > >>
> > >>>
> > >>> Agree on it being a user space plugin -- but I was thinking it could
> be
> > >> in
> > >>> cordova-plugins maybe when the time comes
> > >>
> > >> I would love for it to be a cordova core plugin
> > >>
> > >>>
> > >>>
> > >>> On Fri, Feb 21, 2014 at 1:47 PM, Joe Bowser <bo...@gmail.com>
> wrote:
> > >>>
> > >>>> Is this actually running a service?  I thought this just runs a
> > >>>> Cordova App in the background, which Android already has a setting
> > >>>> for.
> > >>>>
> > >>>> On Fri, Feb 21, 2014 at 1:44 PM, Brian LeRoux <b...@brian.io> wrote:
> > >>>>> I think its cool as a user space plugin for now though. Have you
> > >>>> published
> > >>>>> it to http://plugins.cordova.io ? (Its just like npm / you can
> read
> > up
> > >>>> on
> > >>>>> how here: https://github.com/apache/cordova-plugman)
> > >>>>>
> > >>>>> I really like the idea of us looking at background processing.
> > >>>>>
> > >>>>> Android services: how would that work? Does Firefox OS have the
> > concept
> > >>>> of
> > >>>>> background services? I know Chrome Mobile Apps guys have been doing
> > >> some
> > >>>>> thinking here too.
> > >>>>>
> > >>>>>
> > >>>>> On Fri, Feb 21, 2014 at 2:53 AM, Erik Jan de Wit <
> edewit@redhat.com>
> > >>>> wrote:
> > >>>>>
> > >>>>>> Hi,
> > >>>>>>
> > >>>>>> I've created an initial version for
> > >>>>>> https://issues.apache.org/jira/browse/CB-4846 the plugin is
> located
> > >> at
> > >>>>>> https://github.com/edewit/cordova-background-plugin
> > >>>>>>
> > >>>>>> Cheers,
> > >>>>>>       Erik Jan
> > >>>>
> > >>
> > >>
> >
> >
>

Re: CB-4846

Posted by Shazron <sh...@gmail.com>.
That is odd, if calling into JavaScript from being in the background works,
the pluginResult method should work as well. Might be worth investigating


On Tue, Feb 25, 2014 at 12:05 AM, Erik Jan de Wit <ed...@redhat.com> wrote:

> Hi Shazron,
>
> Actually I started out building it this way, I've changed it to way it's
> now, because it didn't work. Once the application has moved to the
> background trying to invoke the method with the plugin result no longer
> works. I've seen other plugins use the 'named' callback 'trick' and thought
> that was the way to invoke a callback from background. Shall I try to
> investigate why this is not working?
>
> Cheers,
>         Erik Jan
>
> On 24 Feb,2014, at 19:36 , Shazron <sh...@gmail.com> wrote:
>
> > Hi Erik,
> > The gist of it is here:
> >
> http://cordova.apache.org/docs/en/3.4.0/guide_platforms_ios_plugin.md.html#iOS%20Plugins
> >
> > Basically, you have to modify your js interface to take in a success and
> > failure callback. Then, in native code you create a PluginResult and set
> it
> > to a specific command status (CDVCommandStatus_*), then send it back
> > through the commandDelegate - it will figure out how to route it
> properly.
> > There are examples in the link above.
> >
> >
> > On Sun, Feb 23, 2014 at 11:38 PM, Erik Jan de Wit <ed...@redhat.com>
> wrote:
> >
> >>
> >> On 22 Feb,2014, at 0:01 , Shazron <sh...@gmail.com> wrote:
> >>
> >>> Joe - this calls a background fetch handler for your app at an
> interval,
> >> it
> >>> doesn't really run in the background.
> >>>
> >>> Erik - just a quick code review:
> >>> 1. The method swizzling stuff is great but what I have planned
> (sometime
> >> in
> >>> the future, in progress) is this:
> >>> https://issues.apache.org/jira/browse/CB-5601
> >>
> >> Ahh cool, I'll keep an eye on that one.
> >>
> >>> 2. The way you are using callbacks is not quite correct
> >>
> >> Could you elaborate on that, I'll be more then happy to fix it
> >>
> >>>
> >>> Agree on it being a user space plugin -- but I was thinking it could be
> >> in
> >>> cordova-plugins maybe when the time comes
> >>
> >> I would love for it to be a cordova core plugin
> >>
> >>>
> >>>
> >>> On Fri, Feb 21, 2014 at 1:47 PM, Joe Bowser <bo...@gmail.com> wrote:
> >>>
> >>>> Is this actually running a service?  I thought this just runs a
> >>>> Cordova App in the background, which Android already has a setting
> >>>> for.
> >>>>
> >>>> On Fri, Feb 21, 2014 at 1:44 PM, Brian LeRoux <b...@brian.io> wrote:
> >>>>> I think its cool as a user space plugin for now though. Have you
> >>>> published
> >>>>> it to http://plugins.cordova.io ? (Its just like npm / you can read
> up
> >>>> on
> >>>>> how here: https://github.com/apache/cordova-plugman)
> >>>>>
> >>>>> I really like the idea of us looking at background processing.
> >>>>>
> >>>>> Android services: how would that work? Does Firefox OS have the
> concept
> >>>> of
> >>>>> background services? I know Chrome Mobile Apps guys have been doing
> >> some
> >>>>> thinking here too.
> >>>>>
> >>>>>
> >>>>> On Fri, Feb 21, 2014 at 2:53 AM, Erik Jan de Wit <ed...@redhat.com>
> >>>> wrote:
> >>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>> I've created an initial version for
> >>>>>> https://issues.apache.org/jira/browse/CB-4846 the plugin is located
> >> at
> >>>>>> https://github.com/edewit/cordova-background-plugin
> >>>>>>
> >>>>>> Cheers,
> >>>>>>       Erik Jan
> >>>>
> >>
> >>
>
>

Re: CB-4846

Posted by Erik Jan de Wit <ed...@redhat.com>.
Hi Shazron,

Actually I started out building it this way, I’ve changed it to way it’s now, because it didn’t work. Once the application has moved to the background trying to invoke the method with the plugin result no longer works. I’ve seen other plugins use the ‘named’ callback ’trick’ and thought that was the way to invoke a callback from background. Shall I try to investigate why this is not working?

Cheers,
	Erik Jan 

On 24 Feb,2014, at 19:36 , Shazron <sh...@gmail.com> wrote:

> Hi Erik,
> The gist of it is here:
> http://cordova.apache.org/docs/en/3.4.0/guide_platforms_ios_plugin.md.html#iOS%20Plugins
> 
> Basically, you have to modify your js interface to take in a success and
> failure callback. Then, in native code you create a PluginResult and set it
> to a specific command status (CDVCommandStatus_*), then send it back
> through the commandDelegate - it will figure out how to route it properly.
> There are examples in the link above.
> 
> 
> On Sun, Feb 23, 2014 at 11:38 PM, Erik Jan de Wit <ed...@redhat.com> wrote:
> 
>> 
>> On 22 Feb,2014, at 0:01 , Shazron <sh...@gmail.com> wrote:
>> 
>>> Joe - this calls a background fetch handler for your app at an interval,
>> it
>>> doesn't really run in the background.
>>> 
>>> Erik - just a quick code review:
>>> 1. The method swizzling stuff is great but what I have planned (sometime
>> in
>>> the future, in progress) is this:
>>> https://issues.apache.org/jira/browse/CB-5601
>> 
>> Ahh cool, I'll keep an eye on that one.
>> 
>>> 2. The way you are using callbacks is not quite correct
>> 
>> Could you elaborate on that, I'll be more then happy to fix it
>> 
>>> 
>>> Agree on it being a user space plugin -- but I was thinking it could be
>> in
>>> cordova-plugins maybe when the time comes
>> 
>> I would love for it to be a cordova core plugin
>> 
>>> 
>>> 
>>> On Fri, Feb 21, 2014 at 1:47 PM, Joe Bowser <bo...@gmail.com> wrote:
>>> 
>>>> Is this actually running a service?  I thought this just runs a
>>>> Cordova App in the background, which Android already has a setting
>>>> for.
>>>> 
>>>> On Fri, Feb 21, 2014 at 1:44 PM, Brian LeRoux <b...@brian.io> wrote:
>>>>> I think its cool as a user space plugin for now though. Have you
>>>> published
>>>>> it to http://plugins.cordova.io ? (Its just like npm / you can read up
>>>> on
>>>>> how here: https://github.com/apache/cordova-plugman)
>>>>> 
>>>>> I really like the idea of us looking at background processing.
>>>>> 
>>>>> Android services: how would that work? Does Firefox OS have the concept
>>>> of
>>>>> background services? I know Chrome Mobile Apps guys have been doing
>> some
>>>>> thinking here too.
>>>>> 
>>>>> 
>>>>> On Fri, Feb 21, 2014 at 2:53 AM, Erik Jan de Wit <ed...@redhat.com>
>>>> wrote:
>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>> I've created an initial version for
>>>>>> https://issues.apache.org/jira/browse/CB-4846 the plugin is located
>> at
>>>>>> https://github.com/edewit/cordova-background-plugin
>>>>>> 
>>>>>> Cheers,
>>>>>>       Erik Jan
>>>> 
>> 
>> 


Re: CB-4846

Posted by Shazron <sh...@gmail.com>.
Hi Erik,
The gist of it is here:
http://cordova.apache.org/docs/en/3.4.0/guide_platforms_ios_plugin.md.html#iOS%20Plugins

Basically, you have to modify your js interface to take in a success and
failure callback. Then, in native code you create a PluginResult and set it
to a specific command status (CDVCommandStatus_*), then send it back
through the commandDelegate - it will figure out how to route it properly.
There are examples in the link above.


On Sun, Feb 23, 2014 at 11:38 PM, Erik Jan de Wit <ed...@redhat.com> wrote:

>
> On 22 Feb,2014, at 0:01 , Shazron <sh...@gmail.com> wrote:
>
> > Joe - this calls a background fetch handler for your app at an interval,
> it
> > doesn't really run in the background.
> >
> > Erik - just a quick code review:
> > 1. The method swizzling stuff is great but what I have planned (sometime
> in
> > the future, in progress) is this:
> > https://issues.apache.org/jira/browse/CB-5601
>
> Ahh cool, I'll keep an eye on that one.
>
> > 2. The way you are using callbacks is not quite correct
>
> Could you elaborate on that, I'll be more then happy to fix it
>
> >
> > Agree on it being a user space plugin -- but I was thinking it could be
> in
> > cordova-plugins maybe when the time comes
>
> I would love for it to be a cordova core plugin
>
> >
> >
> > On Fri, Feb 21, 2014 at 1:47 PM, Joe Bowser <bo...@gmail.com> wrote:
> >
> >> Is this actually running a service?  I thought this just runs a
> >> Cordova App in the background, which Android already has a setting
> >> for.
> >>
> >> On Fri, Feb 21, 2014 at 1:44 PM, Brian LeRoux <b...@brian.io> wrote:
> >>> I think its cool as a user space plugin for now though. Have you
> >> published
> >>> it to http://plugins.cordova.io ? (Its just like npm / you can read up
> >> on
> >>> how here: https://github.com/apache/cordova-plugman)
> >>>
> >>> I really like the idea of us looking at background processing.
> >>>
> >>> Android services: how would that work? Does Firefox OS have the concept
> >> of
> >>> background services? I know Chrome Mobile Apps guys have been doing
> some
> >>> thinking here too.
> >>>
> >>>
> >>> On Fri, Feb 21, 2014 at 2:53 AM, Erik Jan de Wit <ed...@redhat.com>
> >> wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> I've created an initial version for
> >>>> https://issues.apache.org/jira/browse/CB-4846 the plugin is located
> at
> >>>> https://github.com/edewit/cordova-background-plugin
> >>>>
> >>>> Cheers,
> >>>>        Erik Jan
> >>
>
>

Re: CB-4846

Posted by Erik Jan de Wit <ed...@redhat.com>.
On 22 Feb,2014, at 0:01 , Shazron <sh...@gmail.com> wrote:

> Joe - this calls a background fetch handler for your app at an interval, it
> doesn't really run in the background.
> 
> Erik - just a quick code review:
> 1. The method swizzling stuff is great but what I have planned (sometime in
> the future, in progress) is this:
> https://issues.apache.org/jira/browse/CB-5601

Ahh cool, I’ll keep an eye on that one.

> 2. The way you are using callbacks is not quite correct

Could you elaborate on that, I’ll be more then happy to fix it

> 
> Agree on it being a user space plugin -- but I was thinking it could be in
> cordova-plugins maybe when the time comes

I would love for it to be a cordova core plugin

> 
> 
> On Fri, Feb 21, 2014 at 1:47 PM, Joe Bowser <bo...@gmail.com> wrote:
> 
>> Is this actually running a service?  I thought this just runs a
>> Cordova App in the background, which Android already has a setting
>> for.
>> 
>> On Fri, Feb 21, 2014 at 1:44 PM, Brian LeRoux <b...@brian.io> wrote:
>>> I think its cool as a user space plugin for now though. Have you
>> published
>>> it to http://plugins.cordova.io ? (Its just like npm / you can read up
>> on
>>> how here: https://github.com/apache/cordova-plugman)
>>> 
>>> I really like the idea of us looking at background processing.
>>> 
>>> Android services: how would that work? Does Firefox OS have the concept
>> of
>>> background services? I know Chrome Mobile Apps guys have been doing some
>>> thinking here too.
>>> 
>>> 
>>> On Fri, Feb 21, 2014 at 2:53 AM, Erik Jan de Wit <ed...@redhat.com>
>> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I've created an initial version for
>>>> https://issues.apache.org/jira/browse/CB-4846 the plugin is located at
>>>> https://github.com/edewit/cordova-background-plugin
>>>> 
>>>> Cheers,
>>>>        Erik Jan
>> 


Re: CB-4846

Posted by Shazron <sh...@gmail.com>.
Joe - this calls a background fetch handler for your app at an interval, it
doesn't really run in the background.

Erik - just a quick code review:
1. The method swizzling stuff is great but what I have planned (sometime in
the future, in progress) is this:
https://issues.apache.org/jira/browse/CB-5601
2. The way you are using callbacks is not quite correct

Agree on it being a user space plugin -- but I was thinking it could be in
cordova-plugins maybe when the time comes


On Fri, Feb 21, 2014 at 1:47 PM, Joe Bowser <bo...@gmail.com> wrote:

> Is this actually running a service?  I thought this just runs a
> Cordova App in the background, which Android already has a setting
> for.
>
> On Fri, Feb 21, 2014 at 1:44 PM, Brian LeRoux <b...@brian.io> wrote:
> > I think its cool as a user space plugin for now though. Have you
> published
> > it to http://plugins.cordova.io ? (Its just like npm / you can read up
> on
> > how here: https://github.com/apache/cordova-plugman)
> >
> > I really like the idea of us looking at background processing.
> >
> > Android services: how would that work? Does Firefox OS have the concept
> of
> > background services? I know Chrome Mobile Apps guys have been doing some
> > thinking here too.
> >
> >
> > On Fri, Feb 21, 2014 at 2:53 AM, Erik Jan de Wit <ed...@redhat.com>
> wrote:
> >
> >> Hi,
> >>
> >> I've created an initial version for
> >> https://issues.apache.org/jira/browse/CB-4846 the plugin is located at
> >> https://github.com/edewit/cordova-background-plugin
> >>
> >> Cheers,
> >>         Erik Jan
>

Re: CB-4846

Posted by Joe Bowser <bo...@gmail.com>.
Is this actually running a service?  I thought this just runs a
Cordova App in the background, which Android already has a setting
for.

On Fri, Feb 21, 2014 at 1:44 PM, Brian LeRoux <b...@brian.io> wrote:
> I think its cool as a user space plugin for now though. Have you published
> it to http://plugins.cordova.io ? (Its just like npm / you can read up on
> how here: https://github.com/apache/cordova-plugman)
>
> I really like the idea of us looking at background processing.
>
> Android services: how would that work? Does Firefox OS have the concept of
> background services? I know Chrome Mobile Apps guys have been doing some
> thinking here too.
>
>
> On Fri, Feb 21, 2014 at 2:53 AM, Erik Jan de Wit <ed...@redhat.com> wrote:
>
>> Hi,
>>
>> I've created an initial version for
>> https://issues.apache.org/jira/browse/CB-4846 the plugin is located at
>> https://github.com/edewit/cordova-background-plugin
>>
>> Cheers,
>>         Erik Jan

Re: CB-4846

Posted by Brian LeRoux <b...@brian.io>.
I think its cool as a user space plugin for now though. Have you published
it to http://plugins.cordova.io ? (Its just like npm / you can read up on
how here: https://github.com/apache/cordova-plugman)

I really like the idea of us looking at background processing.

Android services: how would that work? Does Firefox OS have the concept of
background services? I know Chrome Mobile Apps guys have been doing some
thinking here too.


On Fri, Feb 21, 2014 at 2:53 AM, Erik Jan de Wit <ed...@redhat.com> wrote:

> Hi,
>
> I've created an initial version for
> https://issues.apache.org/jira/browse/CB-4846 the plugin is located at
> https://github.com/edewit/cordova-background-plugin
>
> Cheers,
>         Erik Jan