如何在PhoneGap/Cordova上加载外部URL并启用PushNotifications?

6 push-notification ios cordova

我要做的是制作iOS PhoneGap/Cordova应用程序,它唯一能做的就是加载外部URL并启用PushNotifications.

似乎我可以单独做两个,但不能同时做到.

对于PushNotifications我正在使用插件,这看起来很棒.

但是,当我尝试从我的index.html打开外部URL时,PushNotification不起作用.

我正在使用本教程来启用Push iOS PhoneGap/Cordova Push.

在我下载示例代码后,我试图使用这样的东西:

<!DOCTYPE html>
<html>
    <head>
        <title>InAppBrowser.addEventListener Example</title>

        <script src="cordova-2.5.0.js"></script>
        <script src="js/PushNotification.js"></script>
        <script src="js/index.js"></script>
        <script type="text/javascript" charset="utf-8">

            // Wait for Cordova to load
            //
            document.addEventListener("deviceready", onDeviceReady, false);

            // Cordova is ready
            //
            function onDeviceReady() {
                var ref = window.open('http://apache.org', '_blank', 'location=yes');
                ref.addEventListener('loadstart', function() { alert('start: ' + event.url); });
                ref.addEventListener('loadstop', function() { alert('stop: ' + event.url); });
                ref.addEventListener('exit', function() { alert(event.type); });
            }

            </script>
    </head>
    <body>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我包括启用推送所需的脚本index.js和pushnotifications.js.

但我只能看到URL加载并且未启用推送.

如果我尝试这个,推送启用:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name = "format-detection" content = "telephone=no"/>
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width;" />
        <title>Push Notification Tester</title>
        <link href="css/index.css" rel="stylesheet" />
    </head>
    <body>
        <script src="cordova-2.5.0.js"></script>
        <script src="js/PushNotification.js"></script>
        <script src="js/index.js"></script>
        <script type="text/javascript">
            console.log("Test " + app);
            app.initialize();
            </script>

    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

但是当然在这个例子中,我没有像我想的那样使用外部Url.那么我如何在这个代码上添加外部url函数来同时拥有外部url和push?

有任何想法吗?