EddyVerbruggen / Custom-URL-scheme

:link: Launch your Cordova/PhoneGap app by a Custom URL scheme like mycoolapp://
1.03k stars 367 forks source link

openHandleURL function is not working for ios #214

Open hybridapp20161 opened 7 years ago

hybridapp20161 commented 7 years ago

Hi Eddy,

I'm kind of stuck. Even after following the procedure mentioned in the doc openHandleURL() is not working for ios, however it is working fine with Android. Is there anything else that Im missing? Im testing this on simulator and using Iphone 6 (8.3).

And is there any release in future for support of this plugin in higher version of ios.

pliablepixels commented 7 years ago

@hybridapp20161 - it works if you do window.handleOpenURL=function(url){};. I added this inside deviceReady.

hybridapp20161 commented 7 years ago

@pliablepixels Thanks for the reply :)

I tried window.handleOpenUrl=function(url){}; inside deviceReady as you suggested but unluckily didn't work :( . I also tried it inside onLoad() method but again no luck.

window.handleOpenURL = function (url) { setTimeout( function(){ alert(">>>>>>>>>>>>>>"+url); },3000); console.log("window.handleOpenURLStaged = "+url); }

Is there any configuration that Im missing?

Thanks again in advance ;)

pliablepixels commented 7 years ago

Not sure - if you installed the plugin using cordova plugin add the settings would be automatically added. Here is my code where I handled it.

hybridapp20161 commented 7 years ago

Yes I've added the plugin using "cordova plugin add". The URL from browser is able to launch the application but the problem is with the handleOpenUrl() which is not getting triggered.

I've placed an alert and console.log inside the method with setTimeout() but nothing is happening after application launch. Console is also clear. I need some more suggestions :). May be some settings that I need to check that you may suggest.

And I have one more doubt whether iOS 10 and above have support for this plugin or not?

Thanks for the help mate :)

pliablepixels commented 7 years ago

No problem - I'm on IOS 10.1 and it seems to be working for me - the only caveat is I've tried it on debug builds so far - My next app store release is scheduled for later this month, so if it breaks I'll get to know then ;-)

sooonism commented 7 years ago

I am facing the same issue too. I test it in my iPhone6 on iOS 10 and did not get anything at all. I put HandleOpenURL() inside and outside the on(deviceready), both with no luck. Someone please suggest some alternative solutions.

pliablepixels commented 7 years ago

That's odd. I have this code working both on debug and production builds across multiple IOS devices (iPhone 7, iPad pro, both running latest IOS releases)

sooonism commented 7 years ago

I found out that the handerOpenURL only works if the app is already launch. but if I use the link to launch the app, it did not work.

skicson commented 7 years ago

I noticed today that - (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation is not getting called in CDVAppDelegate. However, if I copy the contents of that method to - (BOOL) application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options it then does work as expected.

hybridapp20161 commented 7 years ago

@skicson Thank you a ton for reply. Now my doubt is will my hybrid app will be able to read the url that I will send from native? This is working absolutely fine in Android and in IOS I am able to launch the app but the only problem is I cannot able to read the Text that I send in URL, it is like my openHandleURL function is not getting triggered. Thanks in advance :).

william-beange-hs commented 7 years ago

I am having this issue once upgrading from cordova 6.5.0 to cordova 7.0.1. Work fine on Android, does not work on iOS. The handerOpenURL is never triggered. As described in the comments above I have tried setting handerOpenURL on the window object, setting in the ionicPlatform.ready function. Does not get triggered.

ionic info

Your system information:

Cordova CLI: 7.0.1 
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.1.7
ios-deploy version: 1.9.1 
ios-sim version: 5.0.8 
OS: macOS Sierra
Node Version: v4.7.3
Xcode version: Xcode 8.3.3 Build version 8E3004b
william-beange-hs commented 7 years ago

I figured out what was wrong in my case. I have cordova-plugin-facebook4, com.localytics.phonegap.LocalyticsPlugin plugins installed on my cordova project, each of which include a handerOpenURL function. So one of them is overriding the behavior.

AmyJUn commented 5 years ago

@william-beange-hs how how did you solve the problem?

william-beange-hs commented 5 years ago

@AmyJUn The problem was introduced when we upgraded from cordova 6.5.0 to cordova 7.0.1 because in cordova 6.5.0 the package.json dependencies were installed in the order they were listed and in cordova 7.0.1 the package.json dependencies were changed to be installed in alphabetical order. Once installed alphabetically, cordova-plugin-facebook4 was overriding com.localytics.phonegap.LocalyticsPlugin.

In order to fix, I renamed the com.localytics.phonegap.LocalyticsPlugin package to zzz.localytics.phonegap.LocalyticsPlugin so that it was installed last and so handerOpenURL took priority... it was a hack but it didn't take long and solved our business needs at the time. I'm out of touch with the cordova project at the moment but I'm hoping they've re-introduced the ability to install dependencies in order they are listed and not in alphabetical order.

Here's the fix https://github.com/HootsuiteLabs/localytics-cordova/pull/1 https://github.com/HootsuiteLabs/localytics-cordova/pull/2

AmyJUn commented 5 years ago

@william-beange-hs you save my day. you're right! I take one of plugin out in the project and it works. Thank you so much~~~~