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
New Contributor
AZHARSSOFT
Posts: 5
Registered: ‎06-30-2011
My Device: Bold

Javascript - How to fetch Blackberry DeviceID using Javascript

Hi All,

 

We are creating a Web application which will be hosted on some server, and it will accessed by mobile devices.

I need to get the Device ID of the mobile for authenticating them to access our web page. Is there any way to fetch Blackberry DeviceId using Javascript code

Developer
abarber
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: Javascript - How to fetch Blackberry DeviceID using Javascript

Hi

 

If you are building a webworks app you can do this - alert("PIN: " + blackberry.identity.PIN);

 

If it is just a html page with javascript, then NO.

 

Cheers

 

Andrew

Developer
abarber
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: Javascript - How to fetch Blackberry DeviceID using Javascript

Hi

 

Another method for a NON Webworks app is to add the PIN into the HTTP headers, this can be done by a setting on the BES.

 

You can then authenticate when the page is requested.

 

Obviously this will not work for users with BIS.

 

Cheers

 

Andrew

New Contributor
AZHARSSOFT
Posts: 5
Registered: ‎06-30-2011
My Device: Bold

Re: Javascript - How to fetch Blackberry DeviceID using Javascript

Hi,

 

Thanks for your valuable reply,

do i need yo add reference to access the object "blackberry.identity.PIN", when i execute the code on blackberry emulator am not getting any output

 

I am not using any of Blackberry plugins to  my web app, we are just creating a normal website which can accessed through any device[PC/Mobile/Ipod..]

 

But our clients will open this on Blackberry only [ in far future all mobiles], also we dont give any installer to them, They just type the URL in their BB browser and access this as normal website.

 

When a user open this app on their Blackberry or any mobile device, we need to get their DeviceId when they login and save them in our DB for our business needs.

Retired
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Javascript - How to fetch Blackberry DeviceID using Javascript

The only way you would be able to do this in the browser and not a WebWorks app would be using abarber's suggestion of grabbing the PIN from the header of the request IF that functionality is turned on in the BlackBerry Enterprise Server that they are using.

 

However, that means that the PIN will be sent to every website they visit.

 

The reason this information is not available through regular JavaScript and is not included in the headers by default is because it is a privacy issue.  If you have someone's PIN you can then request them as a contact on BBM etc.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter