我正在使用forge.prefs.get来获取缓存的用户令牌,在iOS和Web上运行良好。我使用backbone.js来渲染所有内容。 在Android上,当尝试使用相同的调用时,我会收到以下错误:
[DEBUG] Native call prefs.get with task.params: {"key":"user"}
[DEBUG] Native call notification.hideLoading with task.params: {}
[INFO] --------- beginning of /dev/log/system
[DEBUG] Returned: {"content":{"message":"Method not supported on this platform","type":"UNAVAILABLE","subtype":null},"callid":"4B01A334-2DC4-4511-A029-2C9D9B131D8C","status":"error"}
运行模拟器时,我得到了这个结果。如果我编译 APK 并安装它,代码将默默失败,并且用户将卡在登录界面。
以下是获取用户信息的代码:
forge.prefs.get('user', function(user){ //success
if(user === null){
alert('USER not found');
App.ViewManager.Login();
}else{
var u = JSON.parse(user);
forge.logging.info(u);
forge.logging.info(u.authentication_token);
App.Utils.authToken = u.authentication_token;
App.ViewManager.Companies();
}
})
这用于存储数据:
forge.prefs.set('user', JSON.stringify(data), function(){},function(){});
在iOS和Web版本中,这个功能完美运行。有什么想法,为什么在安卓4.4上的模拟器中会出现问题?我使用的是Trigger toolkit 2.1.3版本和prefs模块2.0版本。