Coming back from a deeplink


#1

Hello,
I am constructing a zapcode that will have three deeplinks within it to other experiences I’ve created. I got deeplinks to work but haven’t figured out how to come back to the “home” page that offers the three different experiences. The only solution I could think of was to create a new button within the three experiences that link back to the “home” page but I don’t want this button to pop up unless the experience is launched through the deeplink. I’ve read the documentation provided in launch method and thought that maybe my answer but I’m confused on how to code it correctly. I think it needs to be something like if launch method internal link show home button but like I said, I’m not sure the proper way. Any advice?


#2

Hey Molly,

You’re correct about needing to add a button in those experiences linking back to the original experience and that you can use the launchMethod function to determine how the user came to the experience.

In order to help point you in the right direction can I confirm that all 4 experiences are built using Studio?

Mark


#3

Yes Mark, all 4 are built in studio!


#4

In that case, the launchMethod returned will be Z.Device.LaunchMethod.internal_link and you can use that in an if statement to determine whether or not to show the back button.

    if (Z.device.launchMethod() == Z.Device.LaunchMethod.internal_link){
        //show button
    }
    else{
        //don't show button
    }

#5

Mark, I followed what you said and it didn’t give me any errors but it didn’t work.

Here is my script:

var display_shown = symbol.controllers.display.elements.shown;
var display_hidden = symbol.controllers.display.elements.hidden;
Z.Device.LaunchMethod.internal_link
parent.on(“show”, parent_show);
function parent_show() {

// Make sure we start from fully hidden
display_hidden.reset();

// Move to the shown state
display_shown.activate();

}

if (Z.device.launchMethod() == Z.Device.LaunchMethod.internal_link){
symbol.controllers.Deeplink.elements.Show.activate();
}
else { symbol.controllers.Deeplink.elements.Hide.activate();
}


#6

Hard to tell what the issue might be just looking at that code but I’ve put together a couple of projects for you to look through.


Project 1 - Project 1.zpp (2.1 KB)

This project links through to the second project in the show script, it’s almost instantaneous.


Project 2 - Project 2.zpp (186.6 KB)

This project displays some text that states whether the experience was launched internally “I came from Zappar” or not “I didn’t come from Zappar”. This logic is also handled in the show script.

The easiest way to test this works is to preview the first project and it should say “I came from Zappar” once the second project loads. If you preview the second project it should say “I didn’t come from Zappar” as you scanned a code directly.

Hope this helps.