You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Michal Mocny <mm...@google.com> on 2012/10/12 17:11:15 UTC

Notice: Notification of work on Notifications

Hi All!

Notifications seem to be an important and popular feature, but the plugins
we have in the phonegap-plugin repo are a bit of a mess.  I was hoping to
take a stab at fixing that.

I figured I'de start by figuring out where we are at today, and open up
discussions for where we want to be.

(What follows is just what I've discovered so far, as I (mis)understand
it.  Please correct any mistakes)

*Definitions*:


   - *Local Notifications*
      - System timers/alarms that can be set up to fire [periodically] in
      order to poke your app with some intent
      - No UI requirements, I think, just a "wake from sleep" feature
   - *StatusBar Notifications*
      - That awesome bar at the top: you can set up an icon, supply
      ticker-text, and/or configure drop down notification window items
      - Notifications may use sound/vibration/flashing lights to attract
      the attention of user when phone isn't in use
      - Users clicking notification window items will poke your app with
      some intent
      - Lots of features, vary between systems
   - *Push Notifications*
      - External cloud services send messages to your device in response to
      some server action/stimulus
      - Once a push arrives, action should likely be some combination of
      Local/StatusBar Notifications, but there are system limitations

*Goals*:

   - Identify whats possible on each platform (initially android/ios)
   - Unify the api across platforms (as much as possible)
   - Use w3c spec for when possible:
      - http://www.w3.org/TR/notifications/
      - http://www.w3.org/TR/eventsource/ (or maybe not this one..)
   - Organize plugin documentation, and write up a single unified guide
   describing the various pieces and provide simple example
   - Potentially: prepare for move to core plugin, though that is not a
   direct goal

*Current state of the world: *(s/the world/phonegap-plugins/)

*iOS*


   - *LocalNotifications*
   - Needs documentation fixup
      - 6 months since proper update, but the code looks fine (at first
      glance)
   - *PushNotifications*
   - Seems well maintained (Max Ogden +more)
      - Inspired by UA implementation (below) but seems to have a more
      robust api
      - Note from Max: no need for explicit notification api when app is in
      background but do when app is in foreground
   - *UAPushNotifications*
   - Urban Airship (http://urbanairship.com/)
      - We have no local implementation, just a TODO in repro, but found
      external: https://github.com/urbanairship/phonegap-ua-push
      - May be sufficient to just update our readme to point to that repo?
   - *StatusBarNotifier*
      - Seems to just change the top text of the *webview* status bar, so
      this plugin seems to not be a StatusBar notification as I defined above,
      more like an app "title" bar, so plugin seems misnamed.
      - Depends on 3rdparty plugin:
      https://github.com/frankdilo/FDStatusBarNotifierView
      - ios6 only, apparently?
   - *NotificationEx*
   - Not interesting, seems to just implement features that were removed
      from old cordova version

*Android*


   - *LocalNotification*
   - Docs claim similar api to iOS version, but looks different (at first
      glance)
      - Can't see how to register a callback (at first glance) -- so how is
      this useful?  Generic wakeup?
      - 8 months since proper update, and the code looks like it needs work
   - *Push Notification*
   - There is no push notification plugin in the phonegap-plugin repo..
      - However, Max Ogden pointed me to external: GCM-Cordova (Google
      Cloud Messaging) https://github.com/marknutter/GCM-Cordova
         - GCM replaces C2DM as supported android push messaging service
      - Api is different than ios push plugin
      - Also Note from Max: you have to explicitly add things to the status
      bar as opposed to iOS where push notifications automatically get
displayed
      in the UI [for background apps I assume]
   - *StatusBarNotification*
   - Braden recently worked to clean this up to use w3c spec etc
      - I haven't scanned through it to see how much functionality it
      supports

*Open Questions*:


   - StatusBar Notifications: Intended for background services to notify a
   user to start some action (instead of just doing the action without users'
   explicit intent) -- so what does this mean for iOS without background
   services?
   - Are StatusBar notifications ever useful in foreground? Is that against
   some design principle?  Leave that decision to the app developer?  (fwiw:
   w3c spec seems to be a little vague, but no where does it say that
   notifications are to be used only while in background)
   - Push Notifications on ios: Can we intercept these when app is not in
   foreground, or must we just rely on default system behavior?

*Prioritizing Steps Forward:*


   1. StatusBar Notifications on iOS (w3c spec)
   2. Push Notifications on android
   3. Push Notifications on iOS (minor fixup/polyfill hopefully)
   4. Local Notifications on android

-Michal

Re: Notice: Notification of work on Notifications

Posted by Michal Mocny <mm...@chromium.org>.
On Wed, Oct 17, 2012 at 1:59 PM, Andrew Grieve <ag...@chromium.org> wrote:
> I think probably the best thing to do is to just always return false for
> webkitNotifications.checkPermission() on iOS when the app is in the
> foreground.

I assumed permissions is checked only once, so I don't think the value
returned here should be changing outside of first prompt/app refresh.

>
> Any custom UI we attempt will likely not appease developers. Let them
> implement their own in-app notification area if that's what they want.

Fair enough.  I'm going to punt this problem for now, mostly because I
want to get the lower hanging fruit first.  Can evaluate the issue
later based on developer needs.

>
> If the app *is* in the background, then return true
> for webkitNotifications.checkPermission().

If it is in the background, this check could never execute.  There
*is* apparently some temporary time period where ios apps actually can
run in the background, I am not aware of all the rules, but I just
don't think that is sufficient to worry about (Perhaps this explains
it: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html
-- beginBackgroundTaskWithExpirationHandler).

Perhaps we can allow notifications in response to having the app
closed? I'll look into that..

>
> On a related note, trying to implement a background app on iOS might be a
> fun experiment. Maybe a music player?
>
>
> On Wed, Oct 17, 2012 at 11:12 AM, Brian LeRoux <b...@brian.io> wrote:
>
>> Toasts are delicious but what would the iOS analog be? (Guess we could
>> write a toasty impl for iOS which would be a cool feature.)
>>
>> On Wed, Oct 17, 2012 at 7:36 AM, Michal Mocny <mm...@chromium.org> wrote:
>> > Do we want to ignore notifications when app is in foreground (call
>> > onerror), or use a different mechanism, like a custom growl/toast, or
>> > something?
>> >
>> > Either way, since the w3c spec does not specify how to delay local
>> > notifications or use push, there is nothing useful it can do on ios as
>> > is.  I'll write some extension to schedule delayed notifications much
>> > like the existing LocalNotification plugin, but use the w3c spec
>> > wherever possible and with as much overlap with android as possible.
>> >
>> > Fun!
>> >
>> > On Tue, Oct 16, 2012 at 9:04 PM, Filip Maj <fi...@adobe.com> wrote:
>> >> I can.. ? Not sure what your point is.
>> >>
>> >> On 10/16/12 5:56 PM, "Jesse" <pu...@gmail.com> wrote:
>> >>
>> >>>You can't ring your doorbell from inside the house either ...
>> >>>
>> >>>On Tue, Oct 16, 2012 at 5:50 PM, Filip Maj <fi...@adobe.com> wrote:
>> >>>>
>> >>>>>>    - StatusBar Notifications: Intended for background services to
>> >>>>>>notify a
>> >>>>>>    user to start some action (instead of just doing the action
>> without
>> >>>>>>users'
>> >>>>>>    explicit intent) -- so what does this mean for iOS without
>> >>>>>>background
>> >>>>>>    services?
>> >>>>>
>> >>>>>I *think* a fallback to local notification would be the way to handle
>> >>>>>this. (But implementation will probably uncover better.)
>> >>>>
>> >>>> I think this is what tripped me up on iOS a few weeks ago when I
>> >>>>attempted
>> >>>> this myself :)
>> >>>>
>> >>>> On iOS, you _cannot_ dispatch a local notification (to the
>> notification
>> >>>> center / status bar area) if the app is in the foreground.
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>>--
>> >>>@purplecabbage
>> >>>risingj.com
>> >>
>>

Re: Notice: Notification of work on Notifications

Posted by Andrew Grieve <ag...@chromium.org>.
I think probably the best thing to do is to just always return false for
webkitNotifications.checkPermission() on iOS when the app is in the
foreground.

Any custom UI we attempt will likely not appease developers. Let them
implement their own in-app notification area if that's what they want.

If the app *is* in the background, then return true
for webkitNotifications.checkPermission().

On a related note, trying to implement a background app on iOS might be a
fun experiment. Maybe a music player?


On Wed, Oct 17, 2012 at 11:12 AM, Brian LeRoux <b...@brian.io> wrote:

> Toasts are delicious but what would the iOS analog be? (Guess we could
> write a toasty impl for iOS which would be a cool feature.)
>
> On Wed, Oct 17, 2012 at 7:36 AM, Michal Mocny <mm...@chromium.org> wrote:
> > Do we want to ignore notifications when app is in foreground (call
> > onerror), or use a different mechanism, like a custom growl/toast, or
> > something?
> >
> > Either way, since the w3c spec does not specify how to delay local
> > notifications or use push, there is nothing useful it can do on ios as
> > is.  I'll write some extension to schedule delayed notifications much
> > like the existing LocalNotification plugin, but use the w3c spec
> > wherever possible and with as much overlap with android as possible.
> >
> > Fun!
> >
> > On Tue, Oct 16, 2012 at 9:04 PM, Filip Maj <fi...@adobe.com> wrote:
> >> I can.. ? Not sure what your point is.
> >>
> >> On 10/16/12 5:56 PM, "Jesse" <pu...@gmail.com> wrote:
> >>
> >>>You can't ring your doorbell from inside the house either ...
> >>>
> >>>On Tue, Oct 16, 2012 at 5:50 PM, Filip Maj <fi...@adobe.com> wrote:
> >>>>
> >>>>>>    - StatusBar Notifications: Intended for background services to
> >>>>>>notify a
> >>>>>>    user to start some action (instead of just doing the action
> without
> >>>>>>users'
> >>>>>>    explicit intent) -- so what does this mean for iOS without
> >>>>>>background
> >>>>>>    services?
> >>>>>
> >>>>>I *think* a fallback to local notification would be the way to handle
> >>>>>this. (But implementation will probably uncover better.)
> >>>>
> >>>> I think this is what tripped me up on iOS a few weeks ago when I
> >>>>attempted
> >>>> this myself :)
> >>>>
> >>>> On iOS, you _cannot_ dispatch a local notification (to the
> notification
> >>>> center / status bar area) if the app is in the foreground.
> >>>>
> >>>
> >>>
> >>>
> >>>--
> >>>@purplecabbage
> >>>risingj.com
> >>
>

Re: Notice: Notification of work on Notifications

Posted by Brian LeRoux <b...@brian.io>.
Toasts are delicious but what would the iOS analog be? (Guess we could
write a toasty impl for iOS which would be a cool feature.)

On Wed, Oct 17, 2012 at 7:36 AM, Michal Mocny <mm...@chromium.org> wrote:
> Do we want to ignore notifications when app is in foreground (call
> onerror), or use a different mechanism, like a custom growl/toast, or
> something?
>
> Either way, since the w3c spec does not specify how to delay local
> notifications or use push, there is nothing useful it can do on ios as
> is.  I'll write some extension to schedule delayed notifications much
> like the existing LocalNotification plugin, but use the w3c spec
> wherever possible and with as much overlap with android as possible.
>
> Fun!
>
> On Tue, Oct 16, 2012 at 9:04 PM, Filip Maj <fi...@adobe.com> wrote:
>> I can.. ? Not sure what your point is.
>>
>> On 10/16/12 5:56 PM, "Jesse" <pu...@gmail.com> wrote:
>>
>>>You can't ring your doorbell from inside the house either ...
>>>
>>>On Tue, Oct 16, 2012 at 5:50 PM, Filip Maj <fi...@adobe.com> wrote:
>>>>
>>>>>>    - StatusBar Notifications: Intended for background services to
>>>>>>notify a
>>>>>>    user to start some action (instead of just doing the action without
>>>>>>users'
>>>>>>    explicit intent) -- so what does this mean for iOS without
>>>>>>background
>>>>>>    services?
>>>>>
>>>>>I *think* a fallback to local notification would be the way to handle
>>>>>this. (But implementation will probably uncover better.)
>>>>
>>>> I think this is what tripped me up on iOS a few weeks ago when I
>>>>attempted
>>>> this myself :)
>>>>
>>>> On iOS, you _cannot_ dispatch a local notification (to the notification
>>>> center / status bar area) if the app is in the foreground.
>>>>
>>>
>>>
>>>
>>>--
>>>@purplecabbage
>>>risingj.com
>>

Re: Notice: Notification of work on Notifications

Posted by Michal Mocny <mm...@chromium.org>.
Do we want to ignore notifications when app is in foreground (call
onerror), or use a different mechanism, like a custom growl/toast, or
something?

Either way, since the w3c spec does not specify how to delay local
notifications or use push, there is nothing useful it can do on ios as
is.  I'll write some extension to schedule delayed notifications much
like the existing LocalNotification plugin, but use the w3c spec
wherever possible and with as much overlap with android as possible.

Fun!

On Tue, Oct 16, 2012 at 9:04 PM, Filip Maj <fi...@adobe.com> wrote:
> I can.. ? Not sure what your point is.
>
> On 10/16/12 5:56 PM, "Jesse" <pu...@gmail.com> wrote:
>
>>You can't ring your doorbell from inside the house either ...
>>
>>On Tue, Oct 16, 2012 at 5:50 PM, Filip Maj <fi...@adobe.com> wrote:
>>>
>>>>>    - StatusBar Notifications: Intended for background services to
>>>>>notify a
>>>>>    user to start some action (instead of just doing the action without
>>>>>users'
>>>>>    explicit intent) -- so what does this mean for iOS without
>>>>>background
>>>>>    services?
>>>>
>>>>I *think* a fallback to local notification would be the way to handle
>>>>this. (But implementation will probably uncover better.)
>>>
>>> I think this is what tripped me up on iOS a few weeks ago when I
>>>attempted
>>> this myself :)
>>>
>>> On iOS, you _cannot_ dispatch a local notification (to the notification
>>> center / status bar area) if the app is in the foreground.
>>>
>>
>>
>>
>>--
>>@purplecabbage
>>risingj.com
>

Re: Notice: Notification of work on Notifications

Posted by Filip Maj <fi...@adobe.com>.
I can.. ? Not sure what your point is.

On 10/16/12 5:56 PM, "Jesse" <pu...@gmail.com> wrote:

>You can't ring your doorbell from inside the house either ...
>
>On Tue, Oct 16, 2012 at 5:50 PM, Filip Maj <fi...@adobe.com> wrote:
>>
>>>>    - StatusBar Notifications: Intended for background services to
>>>>notify a
>>>>    user to start some action (instead of just doing the action without
>>>>users'
>>>>    explicit intent) -- so what does this mean for iOS without
>>>>background
>>>>    services?
>>>
>>>I *think* a fallback to local notification would be the way to handle
>>>this. (But implementation will probably uncover better.)
>>
>> I think this is what tripped me up on iOS a few weeks ago when I
>>attempted
>> this myself :)
>>
>> On iOS, you _cannot_ dispatch a local notification (to the notification
>> center / status bar area) if the app is in the foreground.
>>
>
>
>
>-- 
>@purplecabbage
>risingj.com


Re: Notice: Notification of work on Notifications

Posted by Jesse <pu...@gmail.com>.
You can't ring your doorbell from inside the house either ...

On Tue, Oct 16, 2012 at 5:50 PM, Filip Maj <fi...@adobe.com> wrote:
>
>>>    - StatusBar Notifications: Intended for background services to
>>>notify a
>>>    user to start some action (instead of just doing the action without
>>>users'
>>>    explicit intent) -- so what does this mean for iOS without background
>>>    services?
>>
>>I *think* a fallback to local notification would be the way to handle
>>this. (But implementation will probably uncover better.)
>
> I think this is what tripped me up on iOS a few weeks ago when I attempted
> this myself :)
>
> On iOS, you _cannot_ dispatch a local notification (to the notification
> center / status bar area) if the app is in the foreground.
>



-- 
@purplecabbage
risingj.com

Re: Notice: Notification of work on Notifications

Posted by Andrew Lunny <al...@gmail.com>.
* agree that status bar and local notifications should, in the fullness of
time, be core plugins
* push notifications are a little trickier, because apps that use wildcard
provisioning profiles can't use push notifications. I'm not sure if just
having the push code in there would cause compilation/app review issues if
it were unused.
* PushWoosh (another push notifications service provider) have also worked
on a plugin:
https://github.com/shaders/pushwoosh-phonegap-build-plugin/

Andrew

On 12 October 2012 12:09, Mike Reinstein <re...@gmail.com> wrote:

> Hey Michal,
>
> Working on notifications would be awesome. One thing I'd like to point out.
> We have a spreadsheet to help track the state of all plugins across all the
> platforms. This may contain info that is helpful:
>
>
> https://docs.google.com/spreadsheet/ccc?key=0Al813Y70ZNWbdC0zRFduOEY2M0tjZWYxOVVUbmVFRGc
>
> I'd also ask, could you please update it with information on any of the
> plugins you are working on? The goal here is to have a central planning doc
> that tracks the state of all plugins at a high level across all platforms.
> Since there are several people working on the new plugin system (myself
> included) this would really help.
>
> -Mike
>
> On Fri, Oct 12, 2012 at 2:14 PM, Michal Mocny <mm...@chromium.org> wrote:
>
> > On Fri, Oct 12, 2012 at 12:01 PM, Brian LeRoux <b...@brian.io> wrote:
> >
> > > Dude, this post wins for best title but also a big THANK YOU for doing
> >
> > all this legwork. I moved into the wiki to help collab/tracking here
> > > http://wiki.apache.org/cordova/Core%20API%20Audit
> > >
> > > Goals are perfectly in line w/ what I'd say is "The Cordova Way".
> > > (Irony quotes somewhat intentional.)
> > >
> > > A quick stab at open queries:
> > >
> > > >    - StatusBar Notifications: Intended for background services to
> > notify
> > > a
> > > >    user to start some action (instead of just doing the action
> without
> > > users'
> > > >    explicit intent) -- so what does this mean for iOS without
> > background
> > > >    services?
> > >
> > > I *think* a fallback to local notification would be the way to handle
> > > this. (But implementation will probably uncover better.)
> > >
> > >
> > > >    - Are StatusBar notifications ever useful in foreground? Is that
> > > against
> > > >    some design principle?  Leave that decision to the app developer?
> > >  (fwiw:
> > > >    w3c spec seems to be a little vague, but no where does it say that
> > > >    notifications are to be used only while in background)
> > >
> > > Totally a user space concern.
> > >
> > >
> > > >    - Push Notifications on ios: Can we intercept these when app is
> not
> > in
> > > >    foreground, or must we just rely on default system behavior?
> > >
> > > What do you mean intercept? You mean can we invoke code if the user
> > > ignores?
> > >
> >
> > I mean, when a push notification arrives, can we customize the
> > notification.  This is just something for me to research, unless experts
> > fill me in first ;)
> >
>

Re: Notice: Notification of work on Notifications

Posted by Mike Reinstein <re...@gmail.com>.
Hey Michal,

Working on notifications would be awesome. One thing I'd like to point out.
We have a spreadsheet to help track the state of all plugins across all the
platforms. This may contain info that is helpful:

https://docs.google.com/spreadsheet/ccc?key=0Al813Y70ZNWbdC0zRFduOEY2M0tjZWYxOVVUbmVFRGc

I'd also ask, could you please update it with information on any of the
plugins you are working on? The goal here is to have a central planning doc
that tracks the state of all plugins at a high level across all platforms.
Since there are several people working on the new plugin system (myself
included) this would really help.

-Mike

On Fri, Oct 12, 2012 at 2:14 PM, Michal Mocny <mm...@chromium.org> wrote:

> On Fri, Oct 12, 2012 at 12:01 PM, Brian LeRoux <b...@brian.io> wrote:
>
> > Dude, this post wins for best title but also a big THANK YOU for doing
>
> all this legwork. I moved into the wiki to help collab/tracking here
> > http://wiki.apache.org/cordova/Core%20API%20Audit
> >
> > Goals are perfectly in line w/ what I'd say is "The Cordova Way".
> > (Irony quotes somewhat intentional.)
> >
> > A quick stab at open queries:
> >
> > >    - StatusBar Notifications: Intended for background services to
> notify
> > a
> > >    user to start some action (instead of just doing the action without
> > users'
> > >    explicit intent) -- so what does this mean for iOS without
> background
> > >    services?
> >
> > I *think* a fallback to local notification would be the way to handle
> > this. (But implementation will probably uncover better.)
> >
> >
> > >    - Are StatusBar notifications ever useful in foreground? Is that
> > against
> > >    some design principle?  Leave that decision to the app developer?
> >  (fwiw:
> > >    w3c spec seems to be a little vague, but no where does it say that
> > >    notifications are to be used only while in background)
> >
> > Totally a user space concern.
> >
> >
> > >    - Push Notifications on ios: Can we intercept these when app is not
> in
> > >    foreground, or must we just rely on default system behavior?
> >
> > What do you mean intercept? You mean can we invoke code if the user
> > ignores?
> >
>
> I mean, when a push notification arrives, can we customize the
> notification.  This is just something for me to research, unless experts
> fill me in first ;)
>

Re: Notice: Notification of work on Notifications

Posted by Michal Mocny <mm...@chromium.org>.
On Fri, Oct 12, 2012 at 12:01 PM, Brian LeRoux <b...@brian.io> wrote:

> Dude, this post wins for best title but also a big THANK YOU for doing

all this legwork. I moved into the wiki to help collab/tracking here
> http://wiki.apache.org/cordova/Core%20API%20Audit
>
> Goals are perfectly in line w/ what I'd say is "The Cordova Way".
> (Irony quotes somewhat intentional.)
>
> A quick stab at open queries:
>
> >    - StatusBar Notifications: Intended for background services to notify
> a
> >    user to start some action (instead of just doing the action without
> users'
> >    explicit intent) -- so what does this mean for iOS without background
> >    services?
>
> I *think* a fallback to local notification would be the way to handle
> this. (But implementation will probably uncover better.)
>
>
> >    - Are StatusBar notifications ever useful in foreground? Is that
> against
> >    some design principle?  Leave that decision to the app developer?
>  (fwiw:
> >    w3c spec seems to be a little vague, but no where does it say that
> >    notifications are to be used only while in background)
>
> Totally a user space concern.
>
>
> >    - Push Notifications on ios: Can we intercept these when app is not in
> >    foreground, or must we just rely on default system behavior?
>
> What do you mean intercept? You mean can we invoke code if the user
> ignores?
>

I mean, when a push notification arrives, can we customize the
notification.  This is just something for me to research, unless experts
fill me in first ;)

Re: Notice: Notification of work on Notifications

Posted by Filip Maj <fi...@adobe.com>.
>>    - StatusBar Notifications: Intended for background services to
>>notify a
>>    user to start some action (instead of just doing the action without
>>users'
>>    explicit intent) -- so what does this mean for iOS without background
>>    services?
>
>I *think* a fallback to local notification would be the way to handle
>this. (But implementation will probably uncover better.)

I think this is what tripped me up on iOS a few weeks ago when I attempted
this myself :)

On iOS, you _cannot_ dispatch a local notification (to the notification
center / status bar area) if the app is in the foreground.


Re: Notice: Notification of work on Notifications

Posted by Brian LeRoux <b...@brian.io>.
Dude, this post wins for best title but also a big THANK YOU for doing
all this legwork. I moved into the wiki to help collab/tracking here
http://wiki.apache.org/cordova/Core%20API%20Audit

Goals are perfectly in line w/ what I'd say is "The Cordova Way".
(Irony quotes somewhat intentional.)

A quick stab at open queries:

>    - StatusBar Notifications: Intended for background services to notify a
>    user to start some action (instead of just doing the action without users'
>    explicit intent) -- so what does this mean for iOS without background
>    services?

I *think* a fallback to local notification would be the way to handle
this. (But implementation will probably uncover better.)


>    - Are StatusBar notifications ever useful in foreground? Is that against
>    some design principle?  Leave that decision to the app developer?  (fwiw:
>    w3c spec seems to be a little vague, but no where does it say that
>    notifications are to be used only while in background)

Totally a user space concern.


>    - Push Notifications on ios: Can we intercept these when app is not in
>    foreground, or must we just rely on default system behavior?

What do you mean intercept? You mean can we invoke code if the user ignores?