Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
ruilima
Posts: 12
Registered: ‎11-19-2012
My Device: non-BlackBerry user
My Carrier: non-BlackBerry user

Alarm or LocalNotification

[ Edited ]

Hello,

I've developed an application using PhoneGap. The application has an alarm system, in other words, at an user-configured time an alarm dialog is displayed, then in this dialog if the user press the "continue" button the application will show a page.

I've managed to put this working in Android, iOS and Windows but not in Blackberry. Anyone has an idea how this is done using BB WebWorks & PhoneGap?

 

 

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Alarm or LocalNotification

Which BlackBerry platform are you targeting with PhoneGap (BBOS, PlayBook, BB10)? Also, have you confirmed that the Phonegap APIs you are using are supported on the noted BlackBerry platform?

http://docs.phonegap.com/en/2.2.0/index.html

 

Are you using the latest version of Phonegap/Cordova?


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Contributor
ruilima
Posts: 12
Registered: ‎11-19-2012
My Device: non-BlackBerry user
My Carrier: non-BlackBerry user

Re: Alarm or LocalNotification

Hello oros!

 

I'm targeting BBOS 7.0 & 7.1 (mobile phone) and using PhoneGap 2.2.

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Alarm or LocalNotification

Thanks for that. Would you happen to have a sample application you could post on JSBin or JSFiddle for us to reproduce / investigate with?

 

Also, which part are you finding to  not work? Is it that the notification isn't appearing at the pre-determined time, the new page isn't opening, etc. The more information you can give the better :-)


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Contributor
ruilima
Posts: 12
Registered: ‎11-19-2012
My Device: non-BlackBerry user
My Carrier: non-BlackBerry user

Re: Alarm or LocalNotification

Well oros, I don't have any code since I don't know how to make this. I've made it working with other systems like Android, iOS and WinPhone. For those I've used the LocalNotification plugins existing in GItHub. But for these functionality I can't find anything to use with BlackBerry.

 

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Alarm or LocalNotification

It seems that Phonegap has a Notification API available inherently that is supported on the BlackBerry platform (i.e. no need for external plugins.)

http://docs.phonegap.com/en/2.2.0/cordova_notification_notification.md.html#Notification

 

Apologies if I'm misunderstanding, but using the above in a Phonegap applicaiton, and then simply using the commands to compile for BlackBerry should provide you with the ability to display an alert.

 

In terms of recognizing when a specific time occurs, are you using any platform-specific functionality for that or just Phonegap / pure HTML5 scripts? If Phonegap / HTML5, the same approach should work on the BlackBerry platform as well.

 

 

If we're looking at a WebWorks API, the Dialog API might be of use:

https://developer.blackberry.com/html5/apis/blackberry.ui.dialog.html

 

You can also integrate directly with the Calendar and schedule an Appointment for the user:

https://developer.blackberry.com/html5/apis/blackberry.pim.appointment.html

 

 

To me it seems that most of what you described should be available through HTML5 and Phonegap APIs though, common across most platforms out there with minimal need to actually customize with native code.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Contributor
ruilima
Posts: 12
Registered: ‎11-19-2012
My Device: non-BlackBerry user
My Carrier: non-BlackBerry user

Re: Alarm or LocalNotification

I need to create an alarm. The alarm has to be raised even if the application is in background. When the alarm is raised a Local Notification (not Notification) is shown, then the user activates (clicks) the LocalNotification and the application opens in a specific html5 page.

 

Android & iOS, used LocalNotification

WinPhone, used Reminder.

 

Is it possible something like this in Blackberry?

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Alarm or LocalNotification

Technically, this should all be possible. With respect to the Local Notification, I believe this functionality is equivalent to the MessageList API community extension:

https://github.com/blackberry/WebWorks-Community-APIs/tree/master/Smartphone/MessageList

 

This API allows you to add a notification to the main system list, and clicking that notification will launch your application.

 

If you need this to be a Dialog, and with Local Noticiation my understanding is that you want the dialog to show even if your applications isn't in the foreground, then you can use this to trigger a global dialog:

https://developer.blackberry.com/html5/apis/blackberry.ui.dialog.html

 

However, you will need to create your own custom extension to invoke your application when the dialog is accepted.

https://developer.blackberry.com/html5/documentation/using_javascript_extensions_1866976_11.html

 

Personally, I would recommend the MessageList approach, in conjunction with the Dialog.

 

On OS7, it certainly is possible to create an application that runs in the background:

https://developer.blackberry.com/html5/documentation/rim_background_element_1265316_11.html


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Contributor
ruilima
Posts: 12
Registered: ‎11-19-2012
My Device: non-BlackBerry user
My Carrier: non-BlackBerry user

Re: Alarm or LocalNotification

Seems nice, but I does this would be scheduled?

The alarm has to be raised once a day, in a hour selected by the user.

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Alarm or LocalNotification

While you can set an appointment in the user's calendar, you won't get the same sort of notification that you're mentioning. As far as I can tell, you would need to implement your own form of "alarm" tracking.

 

For instance, local storage could be leveraged to save any pending alarms. On application launch, or when a new item is added to local storage, you could leverage something as simple as a setTimeout which would trigger an action at a certain point in the future. Once triggered the item would be removed from local storage. While not as elegant as scheduling a reminder, the end result would be fairly close.

 

There may be other options available as well, but the above should be one of the simpler ones, implementation-wise.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.