how can i start app with a link in xamarin ios ..thanks

AtlantisDe 41 Reputation points
2022-03-23T15:18:55.093+00:00

how can i start app with a link in xamarin ios ..thanks

C#

//like this:

openapp.Testmobile://123
Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2022-03-24T07:43:14.557+00:00

    Hello,

    You could use Xamarin.Essentials: Launcher in Xamarin.Forms to open other apps via URI . In iOS 9 and greater, Apple enforces what schemes an application can query for. To specify which schemes you would like to use, you must specify LSApplicationQueriesSchemes in your Info.plist file.

    <key>LSApplicationQueriesSchemes</key>  
    <array>  
        <string>XXX</string>   
    </array>  
    

    In Xamarin.iOS, you could use UIApplication.SharedApplication.OpenUrl(url);. Optionally, the CanOpenUrl method can be used to check if the URI schema can be handled by an application on the device: UIApplication.SharedApplication.CanOpenUrl(url);
    For more details, refer to
    https://developer.apple.com/documentation/uikit/uiapplication/1648685-openurl?language=objc
    https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl?language=objc

    ------UPDATE------

    You couldn't use Xamarin.Essentials.Browser by this way : await Xamarin.Essentials.Browser.OpenAsync("lyft://ridetype?id=lyft_line");
    From the source code, we can see that Xamarin.Essentials.Browser uses SFSafariViewController to load the Uri and keep navigation awareness. But SFSafariViewController provides a visible standard interface for browsing the web, the above URI is not a web URL.

    Best Regards,
    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.