Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(iOS) When the app is closed, handleOpenURL not run #29

Closed
Netpolice opened this issue Aug 5, 2014 · 7 comments
Closed

(iOS) When the app is closed, handleOpenURL not run #29

Netpolice opened this issue Aug 5, 2014 · 7 comments

Comments

@Netpolice
Copy link

Under iOS, the function handleOpenURL not run when the app is closed.

However, if the app is launched but in the background, the function handleOpenURL will run.

Any solution for this issue? Thanks!

@EddyVerbruggen
Copy link
Owner

Can you share your ios project with me so I can take a look?

@Netpolice
Copy link
Author

Found the solution.

for iOS.
The handleOpenURL function MUST put between the < head > & < /head >. The handleOpenURL function will be called when the application is closed.

As I am redirecting the page from index.html to main.html for fixing cannot resolve "index.html" issue, I put one more handleOpenURL function in the index.js, index.js is included in the main.html.
Put one more handleOpenURL function in the index.js for calling when the application is in background mode.

@EddyVerbruggen
Copy link
Owner

Glad you solved it.
If you have a minute please update your last comment (code is missing).

@aabilio
Copy link

aabilio commented Oct 13, 2014

@Netpolice could you explain exactly how you resolve this issue? I have the same problem and I cannot fix it whit your instructions. Thanks.

@terikon
Copy link

terikon commented Oct 14, 2014

@aabilio try my comment #2 (comment)

This resolved the issue for me.

@aabilio
Copy link

aabilio commented Oct 14, 2014

@terikon thanks for your reply. I using this plugin just for iOS and finally solved the problem.
I have the "index.html" redirecting to "main.html" too, and to fix the problem I have to do this:

index.html:

    <!DOCTYPE html>
    <html>
    <head> 
        <title>WOW</title>
        <script>

            // New
            handleOpenURL = function (url) {
                setTimeout(function(){
                    window.localStorage.fromuri = url;
                },0);
            };
            //
            window.location = "./main.html";

        </script>
    </head>
    <body>

    </body>
    </html>

main.html:

<html>
<head>
    <script>
        var handleOpenURL;
        handleOpenURL = function (url) {
            alert("THIS IS EXECUTING WHERE APP IS OPEN IN BACKGORUND: "+url);
        };
        document.addEventListener("deviceready", onDeviceReady, false);
        function onDeviceReady() {
            if ( window.localStorage.fromuri != undefined && window.localStorage.fromuri != 'undefined' ) {
                url = window.localStorage.fromuri;
                window.localStorage.fromuri = undefined;

                alert("THIS IS EXECUTING WHERE APP IS INITIALY CLOSE: "+url);
            }
        };
    </script>
</head>
<body>
    <!-- ... -->
</body>
</html>

That is working for me.

@terikon
Copy link

terikon commented Oct 14, 2014

@aabilio Nice, thank you for sharing. Anyway, I have only one page in my app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants