Universal Links on iOS

Ok thanks Rob. I’ll try it now and I keep you informed

Hi,

I found the solution. To add universal links to your Corona SDK project you must add following lines into your build.settings.
After that, follow the Apple Guide for the server side part (https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html)
 

settings = {     iphone = {         entitlements = {             ["com.apple.developer.associated-domains"] = {                 "applinks:www.mywebsite.com",                 "applinks:www.someothersite.com",            },         }    } }

That works well now !
Thanks Rob Again !

Glad it works!

Rob

Well, almost :frowning:

I just realized that although our app is opened, we cannot put our hands on the URL.

Cold start : the url does not appear in launchArgs.url

Warm start : the event “applicationOpen” is not fired and event.url does not contain the triggering url in “applicationResume”

I guess there is something to be done on your side, hopefully not too much work, any chance it can be done soon ?

Best regards,

You will need to file a feature request for this at http://feedback.coronalabs.com and get some people to vote it up. Since this isn’t on our development radar at this time, it’s not likely something that will get added in the next few months.

Rob

Hi Rob,

We are considering creating a plugin for this feature, do you see a reason why we should not, or could not ?

Maybe a bit too close to the core of the application ?

Regards

I don’t know enough about how it works under the hood to answer that. A plugin might work.

Rob

Hi Rob,

We have tried implementing this using enterprise. We have added this code in objective-C as required by Apple :

-(BOOL)application:(UIApplication \*)application continueUserActivity:(NSUserActivity \*)userActivity restorationHandler:(void (^)(NSArray \* \_Nullable))restorationHandler{ if ([userActivity.activityType isEqualToString: NSUserActivityTypeBrowsingWeb]) { NSURL \*url = userActivity.webpageURL; NSLog(@"%@", url.absoluteString); // Will print --\> https://mydomain.com/parameters } return YES; }

It works 50% : we catch the event on hot start, but it does not work on cold start (whereas it works 100% with an empty project, without Corona)

Also for lua we have no idea on how to trigger in objective-C the event “applicationOpen” with event.url as expected, or provide the url in the launch args for a cold start.

Any hint would be great.

Regards,

Our engineering team is majorly slammed with work right now and I’m going to need them to investigate this. What would really help is if you can produce a test case that is as simple as it can be that demonstrates the problem. Then zip up the project and send it as an attachment to support AT coronalabs.com. In the email be as descriptive as possible.

Thanks

Rob

In my quick action plugin, I just use a runtime event in the main.lua file it seems to work fine on cold start and will app is running. 

- (BOOL)application:(UIApplication \*)application didFinishLaunchingWithOptions:(NSDictionary \*)launchOptions { lua\_State \* myL = \_runtime.L; const char kNameKey[] = "name"; const char kValueKey[] = "testApp"; lua\_newtable( myL ); lua\_pushstring( myL, kValueKey ); // All events are Lua tables lua\_setfield( myL, -2, kNameKey ); // that have a 'name' property lua\_pushstring(myL, "cold start"); lua\_setfield( myL, -2, "openType" ); Corona::Lua::DispatchRuntimeEvent( myL, -1 ); return YES; } --- corona side main.lua Runtime:addEventListener("testApp", function (e) print(e. openType) end)

^you do have to use your own corona delegate

https://docs.coronalabs.com/native/ios/CoronaDelegate.html

There is a great example notification source code

https://github.com/coronalabs/plugins-source-notifications/tree/master/ios/Plugin

Hello everyone. Any update on this feature maybe? Any event maybe added to which we can subscribe from main.lua and get information about universal link URL that opened an app, regardless of start coldness? Cheers

Also one thing I noticed regardless of universal links, but rather is related to custom URL scheme in iOS:

local function onSystemEvent(event)   if event.type == "applicationOpen" and event.url then     -- Do stuff with event.url   end end Runtime:addEventListener("system", onSystemEvent)

Upper method only gets triggered if app is opened with click on scheme based URL in Safari while being in background. If app is killed (wiped from memory) while clicking that scheme based URL in Safari, upper method doesn’t get triggered upon app launch.

Any idea how to get URL in that case?

Cheers