In native Android apps you can define an intent-filter
for an activity in the Manifest file which can open the app when a specific link (e.g. myprotocol://mysite.com/action/data
) is visited from a website or email.
<intent-filter>
<data android:scheme="myprotocol" android:host="mysite.com"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
When I try to add this to the AndroidManifest file in an MvvmCross application, it seems that only the view gets loaded, without ViewModel linked to it. I cannot seem to find any information on how to load the ViewModel and get my intent data (the data
part of the url).
Has anyone done this before?
I have an app that responds to scanning NFC tags and I have a similar situation.
My solution is to add the following in my
OnCreate
override right after I callbase.OnCreate(bundle)
:As the comment says, the Intent is not one coming from MvvmCross. This means the bundle which tells MvvmCross which ViewModel to load is not present. So what I do is to create the ViewModel myself.