Search Unity

Unity Android App Launch-ability from clicked file

Discussion in 'Android' started by sauerkraut, May 25, 2015.

  1. sauerkraut

    sauerkraut

    Joined:
    Feb 21, 2014
    Posts:
    23
    Hi

    I would like to build the ability into my game for users to share levels that they have designed in my in-game level designer with their friends.

    I know I could build my own online server using something like Azure, however then I need maintain a server app, and also worry about all the social integration stuff (and a lot of young players won't be on Facebook, etc but still want to share levels).

    The option I am investigating is to see if I can use file associations on Android / iOS to open my game automatically when the user clicks on a hyperlink or attachment in an email representing a file with a specific extension relating to my savegame file.

    Android OS should then be able to know that this file extension is associated to my game and open my game app if it is not already open and somehow trigger a "load level" event or similar and allow me to open the file. Hopefully this type of thing would work in iOS also. Something akin to clicking on a attached PDF in an email and having a choice of installed PDF readers displayed which then run when I click it.

    I am not a native Android developer. I have looked in the App Store, but have found nothing that looks like it would work.

    Is this possible with Unity?

    Many thanks in advance.
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Yes, that is absolutely possible on Android.

    As you may have noticed, other apps are already associated with certain file types, for example:
    • Image files are linked to photo viewing apps
    • PDF is linked to Acrobat reader or similar apps
    In order to support this scenario, you'd need to define a scheme and register your game with it. When a user will click on a link that matches this scheme, your game will be launched.

    See this link for further reference on how to setup schemes (they are added to the AndroidManifest.xml file): http://developer.android.com/guide/topics/manifest/data-element.html

    This link can also help in demonstrating what you need to add to your manifest: http://stackoverflow.com/questions/3760276/android-intent-filter-associate-app-with-file-extension

    The second part is - how the game should handle "launching from a file link" ?
    On Android, you could query the URL that was used to launch the game. In your game, you'll have some method that checks whether this launch URL is in a given format (e.g: a level file) and then invoke whatever logic you want for loading that level, etc.
     
  3. sauerkraut

    sauerkraut

    Joined:
    Feb 21, 2014
    Posts:
    23
    Hi liortal - this has got me started on a solution.

    Many thanks for taking the time to reply.
     
  4. walkmn

    walkmn

    Joined:
    Nov 5, 2013
    Posts:
    2
    Great, but what about ios?