Re: How to load an external URL on PhoneGap/Cordova and have PushNotifications enabled?

3,852 views
Skip to first unread message

jcesarmobile

unread,
Apr 29, 2013, 12:44:59 PM4/29/13
to phon...@googlegroups.com
Don't load external urls, apple won't approve your app

El domingo, 28 de abril de 2013 13:55:07 UTC+2, mroizo escribió:
Did you find a solution?

I need to do exactly the same and I don't know how... 

Hope you can help me!

On Monday, 11 March 2013 17:18:21 UTC+1, Vasilis Lessis wrote:

What i am trying to do is make an iOS PhoneGap/Cordova application that , the only thing it does is load an external URL and have PushNotifications Enabled.

It seems that i can do both separately but not both together.

For the PushNotifications i am using a plugin , which seems to work great.

However when i try to open an external URL from my index.html , the PushNotification doesnt work.

i am trying 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 scripts index.js and pushnotifications.js that are needed to enable the push.

But i can only see the URL loading and the push is not enabled.

If i try this , the push is 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 am not using an external Url as i would like. So how would i add on this code the external Url function to have both external url and push ?

Any ideas?


Kaan Soral

unread,
Apr 29, 2013, 2:28:51 PM4/29/13
to phon...@googlegroups.com
You can't load internal js/css files from an external url by the way. might be the source of your problems, you have to put all your css/js files on the external directory too, cordova.js etc. - a huge amount of bandwidth waste - a major reason not to use external urls

mroizo

unread,
Apr 29, 2013, 2:40:50 PM4/29/13
to phon...@googlegroups.com
I know it's not the ideal situation. But in that specific case, the app must be running in the server like is already done for all the others platforms (android, blackberry and winphone). I know it could be rejected but I already have some apps in the AppStore built that way with phonegap and I didn't have any problem with rejections when I do check for internet connection and I throw exceptions if I lose the connection. The point is that I can't use local notifications with phonegap/cordova if I'm running the app on my server. Actually I can't access any phonegap function after that, so maybe it's useless to do the app that way. Maybe I could do the local notifications with objective-c and keep the app with phonegap like it is already?

Adrian Rotaru

unread,
Sep 25, 2013, 11:12:44 AM9/25/13
to phon...@googlegroups.com
I need this too

ra...@wealthspectrum.com

unread,
May 15, 2014, 6:37:32 AM5/15/14
to phon...@googlegroups.com
Any solution found for this?

I was trying to build external URL application using phonegap.  But due to load,  i switched to Native App and opening external URL using WebView and replacing all resource file references by local resources.  This is working fine for me.  Now I want to implement Push Notification into this.  Is it possible (provided I refer local files from external URL) ?

Kaan Soral

unread,
May 15, 2014, 1:49:08 PM5/15/14
to phon...@googlegroups.com
Yes, open a local page in phonegap and load the external page into the local page

Nuno Vidal

unread,
Jul 31, 2014, 6:19:15 AM7/31/14
to phon...@googlegroups.com
Can you please elaborate a bit more, and possibly include example source code?

I am having the same problem with but with barcodescanner plugin. With Phonegap I set the source to be the external URL of my website instead of the internal index.html - the site open great, but then I'm having a hard time to make the call to the barcodescanner plugin to work. Any tips?

Thank you. 
Reply all
Reply to author
Forward
0 new messages