使用WL.Client.connect和移动Web环境创建简单的应用程序,请参阅"访问被拒绝"在预览和实际设备上运行时

时间:2015-12-11 21:39:48

标签: ibm-mobilefirst

创建了一个简单的混合应用程序。只在代码中包含以下内容

main.js

function wlCommonInit() {
   WL.Client.connect({
      onSuccess: function() {alert ("OK");},
      onFailure: function (string) {alert ("fail" + string);}
   });
}

我创建了一个移动网络环境。

完成Build All Environment后,在服务器上运行它。 我右键点击移动网络环境>预览

我不停地收到一个弹出警报,说“#34;访问被拒绝"使用名为reload的按钮

我移动到我的iphone和Safari中,输入了移动网站的URL。我的iphone上出现了完全相同的错误。

请协助。 This is what it looks like on iphone

1 个答案:

答案 0 :(得分:2)

您还没有告诉我们您使用的是什么版本的MobileFirst Platform Foundation,但我猜它是7.1。

在7.1中,引入了新的Session-Independent Mode,默认情况下处于启用状态。但是,基于浏览器的环境(例如移动Web)不支持与会话无关的模式。如果您尝试在不支持会话的环境中使用为会话无关模式配置的应用,则会出现此错误。如果要在7.1中创建使用基于浏览器的环境的应用程序,则需要禁用与会话无关的模式。

如果你进入你的项目" worklight.properties"文件,设置(或更改)这些值:

12-11 22:22:42.070 405-728/system_process I/ActivityManager: START u0 {act=android.intent.action.CALL dat=tel:xxx flg=0x3000000 cmp=com.android.phone/.OutgoingCallBroadcaster} from pid 24499
12-11 22:22:42.172 647-647/com.android.phone V/OutgoingCallBroadcaster: onCreate: this = com.android.phone.OutgoingCallBroadcaster@41c553b8, icicle = null
12-11 22:22:42.172 647-647/com.android.phone V/OutgoingCallBroadcaster:  - getIntent() = Intent { act=android.intent.action.CALL dat=tel:xxx flg=0x3000000 cmp=com.android.phone/.OutgoingCallBroadcaster }
12-11 22:22:42.188 647-647/com.android.phone V/OutgoingCallBroadcaster:  - configuration = {1.0 ?mcc?mnc en_GB ldltr sw853dp w853dp h1206dp 240dpi xlrg port finger -keyb/v/h -nav/h s.8 themeResource=system}
12-11 22:22:42.188 647-647/com.android.phone V/OutgoingCallBroadcaster: processIntent() = Intent { act=android.intent.action.CALL dat=tel:xxx flg=0x3000000 cmp=com.android.phone/.OutgoingCallBroadcaster }, thread: Thread[main,5,main]
12-11 22:22:42.188 647-647/com.android.phone I/OutgoingCallBroadcaster: This device is detected as non-voice-capable device.
12-11 22:22:42.188 647-647/com.android.phone V/OutgoingCallBroadcaster: handleNonVoiceCapable: handling Intent { act=android.intent.action.CALL dat=tel:xxx flg=0x3000000 cmp=com.android.phone/.OutgoingCallBroadcaster } on non-voice-capable device...
12-11 22:22:42.188 647-647/com.android.phone V/OutgoingCallBroadcaster: - relaunching as a DIAL intent: Intent { act=android.intent.action.DIAL dat=tel:xxx }
12-11 22:22:42.195 405-720/system_process I/ActivityManager: START u0 {act=android.intent.action.DIAL dat=tel:xxx cmp=android/com.android.internal.app.ResolverActivity} from pid 647
12-11 22:22:42.203 647-647/com.android.phone V/OutgoingCallBroadcaster: At the end of onCreate(). isFinishing(): true
12-11 22:22:42.461 405-421/system_process I/ActivityManager: Displayed android/com.android.internal.app.ResolverActivity: +255ms (total +305ms)

然后重建/部署你的项目,它应该工作。

请参阅我上面链接的文档页面,了解有关会话无关模式的更多信息。