Ich habe eine Android-App lokal auf meinem Gerät entwickelt (App noch nicht im Android Play Store). Ich habe die folgende Logik, um einen tiefen Link in MainActivity zu erhalten.
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, null)
.addApi(AppInvite.API)
.build();
// Check if this app was launched from a deep link. Setting autoLaunchDeepLink to true
// would automatically launch the deep link if one is found.
boolean autoLaunchDeepLink = false;
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
.setResultCallback(
new ResultCallback<AppInviteInvitationResult>() {
@Override
public void onResult(@NonNull AppInviteInvitationResult result) {
if (result.getStatus().isSuccess()) {
// Extract deep link from Intent
Intent intent = result.getInvitationIntent();
String deepLink = AppInviteReferral.getDeepLink(intent);
Toast.makeText(getApplicationContext(), deepLink, Toast.LENGTH_LONG).show();
// Handle the deep link. For example, open the linked
// content, or apply promotional credit to the user's
// account.
// ...
} else {
Log.d(TAG, "getInvitation: no deep link found.");
}
}
});
Ich habe einige dynamische Links mit der Firebase-Konsole erstellt und im mobilen Browser geöffnet. Aber es öffnet meine App nicht und erreicht die Zeile String deepLink = AppInviteReferral.getDeepLink(intent);
Stattdessen wird die URL im mobilen Browser selbst geöffnet.
Wie öffne ich die App und handhabe Deep-Links in der Aktivität, während ich den dynamischen Firebase-Link verwende?
Bearbeiten:
Ich habe einen Absichtsfilter in der Manifestdatei.
<activity android:name="MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="example.com" android:scheme="http"/>
<data android:host="example.com" android:scheme="https"/>
</intent-filter>
</activity>
Haben Sie den Intent-Filter im Manifest deklariert? Haben Sie die Konsole auch korrekt mit Ihrem SHA-1-Fingerabdruck eingerichtet?
– NSimon
3. Juni 2016 um 9:42 Uhr
@NicolasSimon, ja, ich habe einen Absichtsfilter im Manifest. und Setup-Konsole richtig. Aktualisiertes Detail in Frage.
– Benutzer3559471
3. Juni 2016 um 9:45 Uhr
Nur eine Randnotiz – achten Sie darauf, den android:host unter zu platzieren (genau wie oben angegeben), da der Link sonst nicht korrekt geöffnet wird. das war mein Problem.
– ilibilibom
8. Januar 2020 um 9:10 Uhr