How do I load an external URL into PhoneGap / Cordova and enable PushNotifications?

What I'm trying to do is make an iOS PhoneGap / Cordova application, which the only thing it does is load an external URL and enable PushNotifications.

It seems that I can do it separately, or not both together.

For PushNotifications, I use a plugin that seems to work fine.

However, when I try to open an external URL from my index.html, PushNotification does not work.

I use this tutorial to enable Push iOS PhoneGap / Cordova Push .

And after I download the sample code, I try to use something like this:

<!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> 

and I include the index.js and pushnotifications.js scripts that are needed to enable push.

But I can only see the URL loading and clicking is not enabled.

If I try, pressing will be enabled:

 <!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> 

But, of course, in this example I do not use an external URL as I would like. So, how would I add an external Url function to this code to have both an external url and push?

Any ideas?

+6
source share

All Articles