How to prevent deep linking from mobile site in an

2019-03-05 23:41发布

问题:

I have added deep links to all of my activities like this.

          <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.BROWSABLE"/>
          <category android:name="android.intent.category.DEFAULT"/>
          <data
              android:host="www.example.com"
              android:path="/stores"
              android:scheme="https" />
          </intent-filter>

This works fine when I am calling within app using uri like this:

android-app://com.example.app/https/www.example.com/stores

But when I am visiting mobile site to this pages it gives me multiple options to open page in app or browser: https://www.example.com/stores. I have some pages which show only when user is logged in but if user logins from mobile site it will redirect to app and it breaks. I don't want to use custom schema.

回答1:

you need to check login status of the user in the entry point of your activities and show the login activity (or dialog) to them if they are not logged in.

you must handle this yourself in your different activities. which re available through deep linking. just check the logged in status each time these activities open and direct to login activity or dialog in the case they need.

if you dont want your browser to add your your application in the list of URI intent suggestions, just delete the "browsable" like below:

   <intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT"/>
      <data
          android:host="www.example.com"
          android:path="/stores"
          android:scheme="https" />
      </intent-filter>