2014-12-06 48 views

回答

3

根据Mozilla的app permissions page,有一个名为“phonenumberservice”的权限,但没有关于它的任何信息。无论如何,Permision已列在“内部(已认证)应用程序权限”下,这意味着只有“系统级应用程序和由Mozilla/operators/OEMs创建的默认应用程序”才能使用它。

+1

谢谢。这意味着我无法获得电话号码! :( – 2014-12-06 17:02:07

1

所以,@Jason说,移动标识API提供了这种能力,而不是只为认证,但特权应用。所以它不再仅限于OEM。

Mozilla Wiki网站显示的API:

dictionary MobileIdOptions { 
    boolean forceSelection = false; 
}; 
partial interface Navigator { 
    Promise getMobileIdAssertion(optional MobileIdOptions options); 
}; 

该网站还为此提供了一个示例代码框架:

function verifyAssertion(aAssertion) { 
    // Make use of the remote verification API 
    // and return the verified msisdn. 
    // NB: This is necessary to make sure that the user *really* controls this phone number! 
} 

// Request a mobile identity assertion and force the chrome UI to 
// allow the user to change a possible previous selection. 
navigator.getMobileIdAssertion({ forceSelection: true }) 
.then(
    (assertion) => { 
     verifyAssertion(assertion) 
     .then(
      (msisdn) => { 
       // Do stuff with the msisdn. 
      } 
     ); 
    }, 
    (error) { 
     // Process error. 
    }; 
); 

对于这个工作,你需要添加mobileid许可的清单文件,例如像这样(我做了说明):

"permissions": { 
    "mobileid": { 
     "description": "Required for sending SMS for two factor authentication", 
     "access": "readonly" 
    } 
} 

PS:我提出了这个答案,因为大多数答案都是过时的,而不是那个答案,并不包含所有有用的信息。

参考文献:

+0

我知道这个答案是几年前,但我想知道:verifyAssertion应该做些什么?联系MSISDN验证服务器? – nuno 2017-03-09 09:43:35