[Xamarin Blog] Creating Connected App Experiences with App Links

JonathanDickJonathanDick Jonathan DickCAXamarin Team, Developer Group Leader Xamurai

Just posted: Creating Connected App Experiences with App Links on the Xamarin Blog.

Read the full article to learn how to use AppLinks in your own Xamarin.iOS, Xamarin.Android and Windows Phone apps to create amazing experiences by deep-linking into other apps.

Use this thread to discuss or ask questions.

Posts

  • AMSAMS Akash Singhal INMember

    Nice work!

    I liked the concept of app links after facebook introduced it at their f8 conference. I'm working on an augmented reality app/game. But I'm using Unity as the game engine. And everyone knows Unity doesn't play well with Xamarin.

    Can Rivets be used independently of Xamarin?

    I really want to explore its possible usage within my app. Please forgive me if my comment deviates from your intention to keep the discussion around Xamarin.

  • JonathanDickJonathanDick Jonathan Dick CAXamarin Team, Developer Group Leader Xamurai

    Rivets is all c# but in its current state you would have to do a bit of work to decouple it completely from Android/iOS. Having said that you can use it compiled for plain .net 4.5 desktop but it may not do exactly what you want in that case.

    I'm planning on updating the library very soon (next week likely) so I'll consider doing some refactoring to make it more platform agnostic friendly :)

  • AMSAMS Akash Singhal INMember

    The app that I'm making is Android/iOS based. Looking forward to your update :D

  • JonathanDickJonathanDick Jonathan Dick CAXamarin Team, Developer Group Leader Xamurai

    @AMS actually just looking at the code again (since it's been awhile), there's really nothing stopping you from just using the .NET 4.5 code and implementing your own IAppLinkNavigator... Or, even more simply, just use the HttpClientAppLinkResolver.Resolve or FacebookIndexAppLinkResolver.Resolve methods to get you back a list of app link targets which you can then determine what you want to do with at that point...

  • JurajJanecekJurajJanecek Juraj Janecek SKMember ✭✭

    Hi
    I'm trying to use Rivets in my application, but I'm not able to get it running (iOS, WP, Android). even the source codes from tutorial is not working.
    can you please help me somehow?
    at least on WP i can get running without Rivets (thru system call) but I have nothing in logs.

    D/Mono    ( 1619): Assembly Ref addref Rivets[0xb8697c70] -> Mono.Android[0xb869
    cb40]: 3
    D/Mono    ( 1619): Image addref System.Json[0xb89552c0] -> System.Json.dll[0xb89
    352b8]: 1
    D/Mono    ( 1619): Assembly System.Json[0xb89552c0] added to domain RootDomain,
    ref_count=1
    D/Mono    ( 1619): AOT module 'System.Json.dll.so' not found: dlopen failed: lib
    rary "/data/data/AppLinksAndroid.AppLinksAndroid/lib/System.Json.dll.so" not fou
    nd
    D/Mono    ( 1619): Assembly Ref addref Rivets[0xb8697c70] -> System.Json[0xb8955
    2c0]: 2
    D/Mono    ( 1619): Assembly Ref addref System.Json[0xb89552c0] -> mscorlib[0xb86
    49d20]: 7
    D/Mono    ( 1619): Assembly Ref addref Rivets[0xb8697c70] -> System.Core[0xb86e0
    160]: 3
    D/Mono    ( 1619): Image addref System.Net.Http[0xb8981f40] -> System.Net.Http.d
    ll[0xb89815c8]: 1
    D/Mono    ( 1619): Assembly System.Net.Http[0xb8981f40] added to domain RootDoma
    in, ref_count=1
    D/Mono    ( 1619): AOT module 'System.Net.Http.dll.so' not found: dlopen failed:
     library "/data/data/AppLinksAndroid.AppLinksAndroid/lib/System.Net.Http.dll.so"
     not found
    D/Mono    ( 1619): Assembly Ref addref Rivets[0xb8697c70] -> System.Net.Http[0xb
    8981f40]: 2
    D/Mono    ( 1619): Assembly Ref addref System.Net.Http[0xb8981f40] -> mscorlib[0
    xb8649d20]: 8
    D/Mono    ( 1619): Assembly Ref addref System.Net.Http[0xb8981f40] -> System[0xb
    88e6460]: 4
    D/Mono    ( 1619): Assembly Ref addref Mono.Android[0xb869cb40] -> System[0xb88e
    6460]: 5
    D/Mono    ( 1619): DllImport attempting to load: '/system/lib/libc.so'.
    D/Mono    ( 1619): DllImport loaded library '/system/lib/libc.so'.
    D/Mono    ( 1619): DllImport searching in: '/system/lib/libc.so' ('/system/lib/l
    ibc.so').
    D/Mono    ( 1619): Searching for 'gettid'.
    D/Mono    ( 1619): Probing 'gettid'.
    D/Mono    ( 1619): Found as 'gettid'.
    
  • JonathanDickJonathanDick Jonathan Dick CAXamarin Team, Developer Group Leader Xamurai

    @jjsan this doesn't seem like any errors from the logcat output.

    Can you please provide a bit more info on what you mean by "can't get it to run"?

  • JurajJanecekJurajJanecek Juraj Janecek SKMember ✭✭

    clicking on link wont open browser/app for that link :(

  • JonathanDickJonathanDick Jonathan Dick CAXamarin Team, Developer Group Leader Xamurai

    @JurajJanecek‌ what is the exact link you are trying?

  • JurajJanecekJurajJanecek Juraj Janecek SKMember ✭✭
    edited September 2014

    i'm just trying to open link:

                    try
                                {
                                    Rivets.AppLinks.Navigator.Navigate("http://www.xamarin.com");
                                }
                                catch (Exception ex)
                                {
                                    System.Diagnostics.Debug.WriteLine("Error: "+ex.Message);
                                    System.Diagnostics.Debug.WriteLine("Message: " + ex.InnerException);
    
                                }           
    

    i created also just simple application to test it, but nothing works on WP/iOS/Android

    if I use

                    try
                                {
                                    Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.xamarin.com"));
                                }
                                catch (Exception ex)
                                {
                                    System.Diagnostics.Debug.WriteLine("Error: "+ex.Message);
                                    System.Diagnostics.Debug.WriteLine("Message: " + ex.InnerException);
                                }
    

    it works ok

    in output window i can see
    'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'D:\WPSystem\Apps{7CD44DDE-FE46-4D05-9DF8-578B628BED70}\Install\System.Json.PCL.DLL'. Cannot find or open the PDB file.
    'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'D:\WPSystem\Apps{7CD44DDE-FE46-4D05-9DF8-578B628BED70}\Install\System.Net.Http.DLL'. Symbols loaded.
    'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'D:\WPSystem\Apps{7CD44DDE-FE46-4D05-9DF8-578B628BED70}\Install\System.Net.Http.Primitives.DLL'. Symbols loaded.
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
    A first chance exception of type 'System.Net.WebException' occurred in System.Windows.ni.dll
    A first chance exception of type 'System.Net.WebException' occurred in System.Windows.ni.dll
    A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in System.Net.Http.DLL
    A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.ni.dll
    A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.ni.dll
    A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.ni.dll
    A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.ni.dll

  • JonathanDickJonathanDick Jonathan Dick CAXamarin Team, Developer Group Leader Xamurai

    @JurajJanecek‌ this is a somewhat common misunderstanding of how Rivets actually works.

    You should read this section of the README: https://github.com/xamarin/rivets#using-rivets-in-your-apps

    Basically, you need to get the NavigationResult from your call to Navigate(). If the result is failed, you will know that the page you are trying to load contains no AppLink metadata in it (no web-fallback url either). At this point it's up to you to decide how you want to proceed to load the URL. You may either want to do something like Windows.System.Launcher.LaunchUriAsync () and let the system browser handle it, or you may want to load it inside of a WebView in your own app.

    Rivets makes no assumptions how you want navigation handled if no AppLink data is found for a given URL.

    Hope that helps!

  • DaanAcohenDaanAcohen Daan Acohen NLMember

    Is it also possible to link to my Xamarin Android app without being dependent on a web page? For example, when no browser has been opened and no browser need to be opened (which is the case when you link to an app from an e-mail using an e-mail app). In Android, this seems to be possible: http://stackoverflow.com/a/2958870

  • ScottMacRitchieScottMacRitchie Scott MacRitchie CAMember

    Hi @JonathanDick is it possible to use rivets in a xamarin.forms PCL project from the PCL? I added rivets using nuget to my PCL, plus the ios and android projects. When I try using it similar to this:

    var result = await AppLinks.Navigator.Navigate ("http://xamarin.com");

    I get an error like this:

    You can't call ResolveAppLink from the Portable Library (System.NotImplementedException)
    at Rivets.HttpClientAppLinkResolver+c__async1.MoveNext () [0x00013] in :0

  • PankajGPankajG Pankaj Gupta USMember
    edited November 2015

    @DaanAcohen said:
    Is it also possible to link to my Xamarin Android app without being dependent on a web page? For example, when no browser has been opened and no browser need to be opened (which is the case when you link to an app from an e-mail using an e-mail app). In Android, this seems to be possible: http://stackoverflow.com/a/2958870

    Hi Daan,
    I have achieved the same functionality in Window Phone by executing:
    var launched = await Windows.System.Launcher.LaunchUriAsync(new Uri("YourAppName:message?token=PankajGupta"));

    In this case, you don't need to depend on Web Page.

  • PankajGPankajG Pankaj Gupta USMember

    @ScottMacRitchie said:
    Hi @JonathanDick is it possible to use rivets in a xamarin.forms PCL project from the PCL? I added rivets using nuget to my PCL, plus the ios and android projects. When I try using it similar to this:

    var result = await AppLinks.Navigator.Navigate ("http://xamarin.com");

    I get an error like this:

    You can't call ResolveAppLink from the Portable Library (System.NotImplementedException)
    at Rivets.HttpClientAppLinkResolver+c__async1.MoveNext () [0x00013] in :0

    I resolved this issue by creating Dependency Service. Declared the interface in PCL and implement the functionality in device specific project.

    Interface in PCL
    namespace Test.Mobile.ViewModels
    {
    public interface IOpenPartnerDirect
    {
    void OpenApp(string number);
    }
    }

    Functionality in device specific project:
    [assembly: Dependency(typeof(OpenPartnerDirect))]
    namespace Test.Mobile.WinPhone
    {
    public class OpenAnotherApp: IOpenApp
    {
    public async void OpenApp(string number)
    {
    var launched =
    await Windows.System.Launcher.LaunchUriAsync(new Uri("AppName:login?token=PankajGupta"));
    }
    }
    }

    More information is available at : https://developer.xamarin.com/guides/cross-platform/xamarin-forms/dependency-service/

  • PankajGPankajG Pankaj Gupta USMember

    Can I open the another app by using its name:

    I have debugged end to end Rivets plugins but it does not create end to end URL for opening app by using its name.

    Is it possible, we can open app by its name?

  • PankajGPankajG Pankaj Gupta USMember
    edited November 2015

    Appreciate quick reply

Sign In or Register to comment.