javascript - 从 Objective C + sencha touch 中调用 javascript 函数

标签 javascript objective-c sencha-touch appdelegate

我正在移动设备中创建 1 个应用程序。

从appdelegate(iphone)中,我想调用驻留在我的sencha touch Controller 中的javascript。有人可以帮助我吗?

我真的被困住了。

请帮助我。

提前致谢。

最佳答案

尝试使用自定义 URL 方案。

Sencha API 文档将告诉您将以下代码添加到您的应用程序中::

Ext.application({
name: 'Sencha',
requires: ['Ext.device.Device'],
launch: function() {
    if (Ext.device.Device.scheme) {
        // the application was opened via another application. Do something:
        alert('Applicaton pened via another application: ' + Ext.device.Device.scheme.url);
    }

    // Listen for future changes
    Ext.device.Device.on('schemeupdate', function(device, scheme) {
        // the application was launched, closed, and then launched another from another application
        // this means onReady will not be called again (because the application is already running in the 
        // background) - but this event will be fired
        alert('Applicated reopened via another application: ' + scheme.url);
    }, this);
}
});

为确保此功能有效,请在 packager.json 文件中添加您在打包应用程序时要使用的自定义 URL,如下所示:::

{
...
"rawConfig": "<key>CFBundleURLTypes</key><array><dict><key>CFBundleURLSchemes</key><array><string>sencha</string></array><key>CFBundleURLName</key><string>com.sencha.example</string></dict></array>"
...
}

编辑::目前仅适用于 Sencha Native Packager,不适用于 Phonegap。

关于javascript - 从 Objective C + sencha touch 中调用 javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15363399/

相关文章:

javascript - Firefox element.event 有效,但 element.addEventlistener 无效

javascript - 通过javascript更改checkbox.id

iphone - 如何找出 UITextField 中的当前插入符位置?

android - Android 和 Phonegap 中的推送通知

javascript - html 元素的 Sencha 触摸事件处理程序

javascript - Tornado WebSockets - InvalidStateError "Still in CONNECTING State"

javascript - 通过单击 (x) 按钮元素从列表中删除 DOM 节点

ios - 字符串的静态 NSArray - 如何/在哪里初始化 View Controller

ios - UILongPressGestureRecognizer 不适用于 Googlemap

javascript - jQuery Mobile 与 Sencha Touch