W3C home > Mailing lists > Public > public-device-apis@w3.org > August 2011

[permissions] ACTION-436: Provide an example for Permissions

From: Wonsuk Lee <wonsuk11.lee@samsung.com>
Date: Tue, 23 Aug 2011 15:21:26 +0900
To: public-device-apis@w3.org
Message-id: <007d01cc615c$e3675fb0$aa361f10$%lee@samsung.com>
Sorry. This is TAG version ;)

 

Here is an example for Feature Permissions.

If you have any comment, its more than welcome ;)

 

 

var featureID = "contacts";

 

function doSomeThing() {

// Getting the permission level of a feature

var response = navigator.permissionLevel(featureID);

 

  if (response === 2) {   //  USER_ALLOWED = 2

// Do something with USER_ALLOWED permission

     getContacts(); // Perform an contacts search

     ...

  }

else

// Do something with USER_DENIED permission

alert("This web app will be working except your "+featureID+" information");

}

 

navigator.requestPermission(featureID, doSomeThing);

 

 

Best regards,

Wonsuk.

========================================= 

   (Wonsuk, Lee) / Senior Engineer, Ph.D

SAMSUNG ELECTRONICS Co., LTD. (߲)

Mobile: +82-10-5800-3997

E-mail: wonsuk11.lee@samsung.com

http://www.wonsuk73.com/, twitter: @wonsuk73

-----------------------------------------

Inspire the World, Create the Future !!!

=========================================

 

========================================= 

   (Wonsuk, Lee) / Senior Engineer, Ph.D

SAMSUNG ELECTRONICS Co., LTD. (߲)

Mobile: +82-10-5800-3997

E-mail:  <mailto:wonsuk11.lee@samsung.com> wonsuk11.lee@samsung.com

 <http://www.wonsuk73.com/> http://www.wonsuk73.com/, twitter: @wonsuk73

-----------------------------------------

Inspire the World, Create the Future !!!

=========================================

 
Received on Tuesday, 23 August 2011 06:22:25 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:46:04 UTC