How to read parameter from a url

131
2
01-12-2021 09:39 AM
x_d
by
New Contributor III

I want to know how to open specific screen in my app , when some qrcode read from my mobile camera ,and that qrcode contains, a url (my website link) + some parameter. currently I can only open home page of my app, when i try to read qrcode through mobile camera. How can i read the parameter from the url? Please do reply it's urgent

I have tried this 

onOpenUrl: {
    console.log("onOpenUrl:", url);

    var urlInfo = AppFramework.urlInfo(url);

    if (!urlInfo.host.length) {
        console.log("onOpenUrl parameters:", JSON.stringify(urlInfo.queryParameters, undefined, 2));
    }
}
urlInfo is blank and "onOpenUrl parameters:" consoles undefind 

 

Tags (2)
Reply
0 Kudos
2 Replies
ErwinSoekianto
Esri Regular Contributor

@x_d 

 

What does the console.log say? Is it the expected URL? If yes, the rest is just processing the URL object. 

Your code looks correct and it is very similar to the sample, you can also look at the example of this on Survey123 template source code, Survey123/template/SurveyApp.qml around line 219, onOpenUrl signal. I am using Survey123 3.11 and AppStudio 4.4

 

Thank you,

Erwin

x_d
by
New Contributor III

@ErwinSoekianto  Thanks for your reply. And I'm getting the expected url, but when I'm trying to split the parameter from the url then it's not working.

 can you suggest me how to get separate the parameter from the url and then redirect to next page

onOpenUrl: {
         console.log("Open url is:"+url)//suppose the url contains 
                  "https://www.arcgis.com/home/index.html+refno=12345"
         var ref_no= url.split('=')[1]; //to grab my required parameter which is 12345
console.log("REF No Returns:"+ref_no)// it prints nothing total blank 
StackView.push("new_page.qml");        
}

 

Reply
0 Kudos