Custom-URL-scheme icon indicating copy to clipboard operation
Custom-URL-scheme copied to clipboard

openHandleURL function is not working for ios

Open hybridapp20161 opened this issue 8 years ago • 15 comments

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.

hybridapp20161 avatar Dec 09 '16 12:12 hybridapp20161

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

pliablepixels avatar Dec 12 '16 15:12 pliablepixels

@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 ;)

hybridapp20161 avatar Dec 16 '16 07:12 hybridapp20161

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.

pliablepixels avatar Dec 16 '16 15:12 pliablepixels

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 :)

hybridapp20161 avatar Dec 19 '16 08:12 hybridapp20161

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 ;-)

pliablepixels avatar Dec 19 '16 14:12 pliablepixels

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.

sooonism avatar Jan 12 '17 06:01 sooonism

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)

pliablepixels avatar Jan 13 '17 14:01 pliablepixels

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.

sooonism avatar Jan 18 '17 01:01 sooonism

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.

skicson avatar Feb 16 '17 16:02 skicson

@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 :).

hybridapp20161 avatar Mar 27 '17 09:03 hybridapp20161

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 avatar Aug 18 '17 21:08 william-beange-hs

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.

william-beange-hs avatar Aug 18 '17 22:08 william-beange-hs

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

AmyJUn avatar Nov 07 '18 04:11 AmyJUn

@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

william-beange-hs avatar Nov 07 '18 18:11 william-beange-hs

@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~~~~

AmyJUn avatar Nov 08 '18 04:11 AmyJUn