Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Not Getting LaunchArgs Through Deep Link
Started by Mars Interactive Jan 09 2019 08:05 AM

- - - - -
3 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Mars Interactive

[GLOBAL: userInfoPane.html]
Mars Interactive
  • Contributor

  • 169 posts
  • Corona SDK

Hello,

I've set up a Custom URL Scheme and placed an HTML page on the web to open the app using the URL Scheme. I'm getting the URL and its params when the app returns from suspend, but not getting any "launchArgs" (...) when starting the app up.

 

HTML:

window.location = "myapp://This/Is/A/TEST";

main.lua:

local launchArgs = ...

if(launchArgs)then

	native.showAlert( "launchArgs!", require('json').encode(launchArgs), {"OK"} )
end

System Events Listener *This is Working*:

local function onSystemEvent( event )
     
    local launchArgs = event
    launchArgs.type = nil
    launchArgs.name = nil


    if(next(launchArgs) ~= nil)then
        native.showAlert( "launchArgs!", require('json').encode( launchArgs ), {"ok"} )
    end

    

    local eventType = event.type

    if ( eventType == "applicationStart" ) then
        -- Occurs when the application is launched and all code in "main.lua" is executed

    elseif ( eventType == "applicationOpen" ) then
        -- Occurs when the application is asked to open a URL resource (Android and iOS only)

    elseif ( eventType == "applicationResume" ) then
        -- Perform all necessary actions for when the app resumes from a suspended state

    elseif ( eventType == "applicationSuspend" ) then
        -- Perform all necessary actions for when the device suspends the application, i.e. during a phone call

    elseif ( eventType == "applicationExit" ) then
        -- Occurs when the user or OS task manager quits the application

    end
end
 
Runtime:addEventListener( "system", onSystemEvent )

The same issue with the same behavior is happing both on Android and iOS.

Thanks for your help in advance...

 

Mars Team



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,372 posts
  • Enterprise

Can you put together a simple demo app (main.lua, config.lua, build.settings) that demonstrates this problem and drop it in a .zip file and share a link to that here?

 

Thanks

Rob



[TOPIC: post.html]
#3

Mars Interactive

[GLOBAL: userInfoPane.html]
Mars Interactive
  • Contributor

  • 169 posts
  • Corona SDK

Hi Rob,

Thank you for your help. As I was preparing an example app, I noticed that the issue was fixed on it. After further investigation, I discovered that the issue was testing on a Corona Live Build version, which, for some reason, doesn't pass any Args on launch.

Not sure if it's a bug or by design, but good to know.

 

Mor from Mars Team.



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,372 posts
  • Enterprise

There probably isn't much that can be done about this. Launch args come in when either the OS launches it (from the URL invocation) or a push notification is interacted with. The OS adds the command line arguments to the launch.

 

When a live build updates, it's like taping on the icon to launch the app. There are no launch args provided in that case. I don't know if a way to keep that command line information exists.

 

Rob




[topic_controls]
[/topic_controls]