notification.confirm not working

453 views
Skip to first unread message

Jonathan

unread,
Oct 21, 2010, 3:55:11 AM10/21/10
to phonegap
Hi
I am trying to use notification.confirm as documented on
http://docs.phonegap.com/phonegap_notification_notification.md.html
but it doesnt work,

I tried this code
var r = navigator.notification.confirm(
'You are the winner!', // message
'Game Over', // title
'Restart,Exit' // buttonLabels
);
navigator.notification.alert('You selected button ' + r);

but this isnt working, ive tried doing this on the latest version
checked out from GIT

Thanks
Jonathan

Jesse MacFadyen

unread,
Oct 21, 2010, 1:44:49 PM10/21/10
to Jonathan, phonegap
The documentation is incorrect ( for iOS )
The call to confirm does not block, so it cannot return the value because the user has NOT chosen anything yet.  The call to confirm returns a delegate, to which you can attach a callback.
The callback is 'onAlertDismissed' and will receive arguments of the index of the button the user chose and the label text displayed on the button the user chose.

Note, navigator.notification.alert returns the exact same thing, so you can know when the alert is dismissed.

This function is available in the upcoming PhoneGap 0.9.2 OR the EDGE version.

This is the correct way to call confirm: 

var delegate = navigator.notification.confirm("You are the winner!","Game Over","Restart,Exit");
delegate.onAlertDismissed = function(index,label)
{
   if(index == 1)
   {
         // user said Exit! do something appropriate
   }
}
> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com



--
--
Jesse MacFadyen
{
  blog:'blogs.nitobi.com/jesse',
  email:'jesse.m...@nitobi.com',
  company:
  {
    name:'Nitobi Software',
    site:'www.nitobi.com',
    phone:
    {
      office:'+1 (604) 685-9287',
      tollFree:'1-866-632-2777'
     }
  }
}

Justin Tyberg

unread,
Oct 21, 2010, 4:04:33 PM10/21/10
to phonegap
This is the way it works on Android and BlackBerry Widgets in 0.9.2/
EDGE. The call to notification.confirm does block and returns the
index of the button pressed.

On Oct 21, 3:55 am, Jonathan <jonathan.fielding.cra...@gmail.com>
wrote:
> Hi
> I am trying to use notification.confirm as documented onhttp://docs.phonegap.com/phonegap_notification_notification.md.html
Reply all
Reply to author
Forward
0 new messages