Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mkdir1995
Visitor

How to go back to home screen after displaying deep linking content?

I have implemented deep linking in my channel and it all works fine. However, when I press the back button, the app exits out when I actually want it to go to the home screen instead. I think this has to do with the fact that there is no screen stack to go back to, but even when I add a screen facade, nothing works. 

This is the gist of what I have: 


    if ( args.ContentId <> Invalid ) and ( args.mediaType <> Invalid )      
      item = findItemById( args.ContentId )      
      if ( item <> Invalid )
        if ( args.mediaType = "episode" or args.mediaType = "movie" or args.mediaType = "short-form" or args.mediaType = "special" )
          'display springboard screen here'  
        else if ( args.mediaType = "season" )
          'display poster screen here'    
        end if 
      end if
    else 
      'showHomeScreen here'
    end if 



I would assume that I could just call the functiojn that displays the home screen after I display the respective screens during deep linking, but that doesn't work either. Any ideas?
0 Kudos
11 REPLIES 11
RokuNB
Roku Guru

Re: How to go back to home screen after displaying deep linking content?

i presume by "home screen" you mean "my app main screen/menu" and not Roku's Home screen.
i see no screen facade in the example above - more details in that direction may help.
0 Kudos
mkdir1995
Visitor

Re: How to go back to home screen after displaying deep linking content?

"RokuNB" wrote:
i presume by "home screen" you mean "my app main screen/menu" and not Roku's Home screen.
i see no screen facade in the example above - more details in that direction may help.

Hi! 
yes, I meant my app's main screen - in my case, the roGridScreen, that loads up after the splash screen when loading my channel the normal way, as opposed to through deep linking.
I deleted the screen facade from the example, oops. but I ended up moving all of my deep linking code into a separate functioning, and then calling the function like so:
    if ( args.ContentId <> Invalid ) and ( args.mediaType <> Invalid )      
      presentdeepLinkContent( args )
    else
     'show home screen here'
    end if 


and the function that holds the deep linking is:

function presentdeepLinkContent( args ) 
   if ( args.ContentId <> Invalid ) and ( args.mediaType <> Invalid )      
      item = findItemById( args.ContentId )      
      if ( item <> Invalid )
        if ( args.mediaType = "episode" or args.mediaType = "movie" or args.mediaType = "short-form" or args.mediaType = "special" )
          'display springboard screen here'  
        else if ( args.mediaType = "season" )
          'display poster screen here'    
        end if 
      end if
end function


I'm still getting the same issue as before where all the deep linking works, but no matter how I include the roGridScreen function, it doesn't show up. Is a screen facade implementation the only way to get this to work? I'm a bit confused on how a screen facade would help me to bring a user back to the home grid screen.
0 Kudos
belltown
Roku Guru

Re: How to go back to home screen after displaying deep linking content?

The channel exits when there are no more screens left on the stack. That's just the way it works.

So, if in your main routine you call presentdeepLinkContent then call showHomeScreen immediately after, your channel will exit after calling presentdeepLinkContent, and never get to showHomeScreen, as there are no more screens left on the stack at that point.
0 Kudos
destruk
Binge Watcher

Re: How to go back to home screen after displaying deep linking content?

It could be as simple to fix as having the gridscreen created and shown without content populated, and then checking for a deeplink id - that way when it returns from the deeplink routine it then populates the existing gridscreen with content.
0 Kudos
mkdir1995
Visitor

Re: How to go back to home screen after displaying deep linking content?

"destruk" wrote:
It could be as simple to fix as having the gridscreen created and shown without content populated, and then checking for a deeplink id - that way when it returns from the deeplink routine it then populates the existing gridscreen with content.

destruk,
at what point would it be best to do this? Inside my if statement that checks for the contentId and MediaType, or in the separate presentdeepLinkContent function
0 Kudos
destruk
Binge Watcher

Re: How to go back to home screen after displaying deep linking content?

When your channel runs, you need to get the launch arguments like you already are and make them available to your channel code.  You have that first part working.
Next you probably want to verify the user account, log them in if necessary, and do your channel prep to prepare the home screen.
You'd want to set up your facade or display something so the channel will not close itself.
Then, at any point after that you would check for the launch parameters - which you only want to act on ONE time per channel launch.
If the parameters are for valid content, and the content is paid for, free, or able to be played, you want the channel to immediately start playing it.  (We used to be able to get away with displaying a springboard screen and having the user click play, but our last submission for this was kicked back and they don't want that anymore, now it has to immediately play if it can)
If the parameters are for valid content, and the content is NOT paid for or authorized, then it should go through the billing sequence immediately and when that completes start playing.
When the content is done playing or the user exits playing then you can display the springboard for the content, and when the user exits that display your main page of content selections.
When you are back at the main page of content, be sure to clean up any leftover variables and ignore or clear the contentID - just good practice so if the user logs out and logs back in, depending on where your branching is, it won't loop back immediately to the original contentID.
0 Kudos
destruk
Binge Watcher

Re: How to go back to home screen after displaying deep linking content?

As you are using roGridScreen for your content display, in Main you get the arguments that are passed in for deep linking,
create your facade screen
If there is a user account needed for your channel/log in required, do that next
Next create the gridscreen, download your xml or json for your content and setup, you can parse everything, call show() for the gridscreen before setting up the categories and content lists for it, and this will show some kind of text "Loading..."  or something there on the gridscreen which is nice IMO.
Check your contentID arguments from the deeplink and handle it from here.
Then when the user returns from that with the back button or something else, populate the category lists for the gridscreen.

That's how we'd do it, but you can try a few other things as you like which work just as well as this sequence.
0 Kudos
destruk
Binge Watcher

Re: How to go back to home screen after displaying deep linking content?

Alternately -- By moving your showhomescreen routine out of the if statement, it will be executed after your presentdeeplinkcontent runs if you have a facade created prior to ensure when presentdeeplinkcontent is done there is something to drop back to between that and showing the home screen.

  if ( args.ContentId <> Invalid ) and ( args.mediaType <> Invalid )      
      presentdeepLinkContent( args )
    end if 
     'show home screen here'
0 Kudos
mkdir1995
Visitor

Re: How to go back to home screen after displaying deep linking content?

"destruk" wrote:
Alternately -- By moving your showhomescreen routine out of the if statement, it will be executed after your presentdeeplinkcontent runs if you have a facade created prior to ensure when presentdeeplinkcontent is done there is something to drop back to between that and showing the home screen.

  if ( args.ContentId <> Invalid ) and ( args.mediaType <> Invalid )      
      presentdeepLinkContent( args )
    end if 
     'show home screen here'


Oh wow, okay. So some questions here:
1) does it say somewhere in the documentation that the deep linking launch needs to immediately play the video? I did not know that! I was launching into a springboard screen, but thanks for the heads up. What if it is a mediaType of "season" and needs to go to the poster screen, will my channel still be rejected during submission? 

my channel has already been published, but in order to submit a new version, I need to implement deep linking. So my app's entire functionality and authentication is working, it's just incorporating it with deep linking that's causing me some trouble. 😄 

2) Alternatively, I created a new object inside my presentdeeplinkcontent function and was add to my screen stack, thus giving me a screen to go back to. However, the when I press the back button after viewing my deep launch content, the home screen function never gets populated on the back button, but rather displays a "Retrieving..." the whole time and I cannot figure out why.

I think what is messing me up is the fact that my screen facade isn't created the correct way. 

function presentdeepLinkContent( args ) 
  m.screen = createObject( "roGridScreen" )
  m.screen.show()

    if ( args.ContentId <> Invalid ) and ( args.mediaType <> Invalid )      
      item = findItemById( args.ContentId )      
      if ( item <> Invalid )
        if ( args.mediaType = "episode" or args.mediaType = "movie" or args.mediaType = "short-form" or args.mediaType = "special" )
          'display springboard screen here'  
        else if ( args.mediaType = "season" )
          'display poster screen here'    
        end if 
      end if
  showHomeScreen()
end function


Thank you!
0 Kudos