Firebase Magic Link in Jetpack Compose - android

I'm working on Firebase's Passwordless Authentication using Android. The Magic Link is received via email, but clicking it only opens the specified URL in Chrome, instead of my app. Here's how things are setup on the client, let me know if relevant code is missing. I've also posted .well-known/assetlinks.json at the root of my site hoping it would help, to no avail.
<!-- AndroidManifest.xml -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="es0329.com" android:scheme="https" />
</intent-filter>
// Screens.kt
sealed class Screens {
object Feed : Screens(
route = "feed",
title = R.string.feed,
icon = Icons.Rounded.TravelExplore
) {
val deepLinks: List<NavDeepLink> = listOf(
navDeepLink {
uriPattern = "$deepLinkBaseUrl$route"
action = Intent.ACTION_VIEW
})
}
}
companion object {
const val deepLinkBaseUrl = "https://es0329.com/"
}
// AuthStore.kt
actionCodeSettings {
url = "${Screens.deepLinkBaseUrl}feed"
handleCodeInApp = true
setAndroidPackageName(
BuildConfig.APPLICATION_ID,
INSTALL_IF_NOT_AVAILABLE,
BuildConfig.VERSION_NAME
)
}
// NavGraph.kt
composable(
route = Feed.route,
deepLinks = Feed.deepLinks
) {
BreweryList()
}

The manifest's opening intent-filter tag was missing the autoVerify attribute.
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="es0329.com" android:scheme="https" />
</intent-filter>

Related

Android compose - Navigation and deep link issues - IllegalArgumentException: navigation destination is not a direct child of this NavGraph

I haave couple of issues with deep linking with compose navigation.
When deeplink is connected to a screen that is in the main Graph it works just fine if the application is cloed, but if its already open the app does not navigate to the target screen. i set android:launchMode="singleTask" in the manifest.
When i try to open a deep link that is connected to a nested graph i get an exception IllegalArgumentException: navigation destination is not a direct child of this NavGraph
I'm not sure how to aproach these issues, Can anyone help me out?
Here are sample of my code:
Manifest
<activity
android:name=".MainActivity"
android:exported="true"
android:label="#string/app_name"
android:screenOrientation="userPortrait"
tools:ignore="LockedOrientationActivity"
android:launchMode="singleTop"
android:theme="#style/Theme.App.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<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="https" />
</intent-filter>
</activity>
Navigation for destination in home graph
composable(
route = NavigationScreen.Item.route,
deepLinks = listOf(navDeepLink {
uriPattern = "${BuildConfig.DEEP_LINK_URI}/items/{itemId}"
}),
enterTransition = flowParentOnTabEnterTransition(),
exitTransition = flowParentOnTabExitTransition(),
popEnterTransition = itemPopEnterTransition(),
popExitTransition = itemPopExitTransition()
) {
it.arguments?.getString("itemId")?.let { itemId ->
ItemScreen(navController, itemId)
}
}
Navigation for destination in nested graph
composable(
route = NavigationSearch.Tag.route,
deepLinks = listOf(navDeepLink { uriPattern = "${BuildConfig.DEEP_LINK_URI}/tag/{id}" }),
arguments = listOf(
navArgument(ARG_TAG_ID) {
type = NavType.StringType
}
),
enterTransition = simpleEnterTransition(),
exitTransition = simpleExitTransition(),
popEnterTransition = simplePopEnterTransition(),
popExitTransition = simplePopExitTransition()
) {
val tagId = it.arguments?.getString(ARG_TAG_ID)
TagScreen(navController, tagId)
}

Android deep linking path pattern

i have this url https://myportal.net/#!/search/main/34 i need to implemnt deep linking when user click on the url its open the app.
Note: 34 number is changing in the url
i do the following but its not working
<activity
android:name="ui.Activities.SplashActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="#style/SplashScreen">
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="${hostName}"
android:pathPattern="/.*/.*/.*/.*"
android:scheme="https" />
</intent-filter>
In Your Splash Activity
private void handleDeepLink(Intent intent) {
FirebaseDynamicLinks.getInstance()
.getDynamicLink(intent)
.addOnSuccessListener(pendingDynamicLinkData -> {
// Get deep link from result (may be null if no link is found)
Uri deepLink;
String finalLink = "";
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
String string = String.valueOf(deepLink);
String decodeUrl = Utils.decodeUrl(string);
String[] parts = decodeUrl.split("main/");
String part1= parts[0];
String part2= parts[1];
finalLink = part2.replaceAll(" ", "+");
Log.w("dynamiclink", finalLink);
if (!Validator.isEmptyString(finalLink)) {
getDataManager().setAuthSecret(finalLink);
}
}
getNavigator().openRegistrationActivity(finalLink);
})
.addOnFailureListener(e -> {
getNavigator().openRegistrationActivity("");
});`
}
In your Manifiest file
<intent-filter android:autoVerify="true">
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:host="nms-rx.in"
android:pathPrefix="main/"
android:scheme="https" />
</intent-filter>

Open URL in my WebView after loading it from YouTube's share menu

I have an Android WebView project and I have added it in the share menu to get the URL from YouTube.
and I am using this code in manifest
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
I need the code to open the URL in the WebView after a click on my app icon from the share menu in YouTube.
For e.g.:
val intent = intent
intent.action = Intent.ACTION_SEND
val uri = intent.data
if (uri == null){
webframe.loadUrl("file:///android_asset/index.html")
}else{
webframe.loadUrl(uri.toString())
}
You can get params in your activity by following code snippet:
Intent intent = getIntent();
Uri uri = intent.getData();
//uri is what you need.
try this:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="www.youtube.com" android:mimeType="text/*" />
</intent-filter>
thanks to everyone I have found a solution to the problem
firs you mut to add this code to manifest:
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="
</intent-filter>
Next add this code to MainActivity:
when (intent?.action) {
Intent.ACTION_SEND -> {
if ("text/plain" == intent.type) {
webframe.loadUrl(intent.getStringExtra(Intent.EXTRA_TEXT))
}
}
else -> {
webframe.loadUrl("file:///android_asset/index.html")
}
}

dribbble authentication url not working in android

This is api doc. http://developer.dribbble.com/v1/oauth/
This is client Ids:
Client ID
3acdea730eaae4ea51dadf296be4e8edf7cd4b6ab030ce69c1de0d1a335b679d
Client Secret
4a9773911cd2304fa23047e703e35fffbd443f32a9c73207aa60b45852e17b64
Client Access Token
57fe6dc09292e4dadce94a3dc9fd895117792a48f7194bbc5b8bd229e6ef1388
Java code
String LOGIN_CALLBACK = "placeholder.com";
String LOGIN_URL = "https://dribbble.com/oauth/authorize?client_id="
+ "3acdea730eaae4ea51dadf296be4e8edf7cd4b6ab030ce69c1de0d1a335b679d"
+ "&redirect_uri=http%3A%2F%2F" + LOGIN_CALLBACK
+ "&scope=public+write+comment+upload";
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(LOGIN_URL)));
in manifest
<activity
android:name=".DribbbleLogin"
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<data
android:host="dribbble-auth-callback"
android:scheme="plain" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
what should be put in callback url and what should be passed in redirect url, so that the flow redirect to my app?
Your callbackUrl should be like plain://example.com and there is one more thing that needs to be done in the android manifest
android:host="example.com"
android:scheme="plain"
Just put in callbackurl "plain://example.com"
in manifest
<activity
android:name=".DribbbleLogin"
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<data
android:host="example.com"
android:scheme="plain" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
In DribbbleLogin Activity
String loginCallback = "electedface.com";
String code;
Intent intent = getIntent();
if (intent != null
&& intent.getData() != null
&& !TextUtils.isEmpty(intent.getData().getAuthority())
&& loginCallback.equals(intent.getData().getAuthority())) {
code = intent.getData().getQueryParameter("code");
}
Call login url "https://dribbble.com//oauth/token" with dribbble_client_id, dribbble_client_secret and this code. you will get access_token, token_type, scope in json.
Thanks All

Android deep link web url with intent-filter

I am trying to launch
https://whereismytrain.in/web/pnr/4353132432 page to launch my activity where I can use 4353132432 number as a variable.
I have declared the following in the manifest file.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="whereismytrain.in"
android:pathPrefix="/web/pnr/(PNR)"
android:scheme="https" />
</intent-filter>
I use the following code in Activity to read it.
urlParamPnr = getArguments().getString("PNR", "");
But this code is not working?
Any idea what's wrong here?
The following code has solved my issue.
Intent urlIntent = getIntent();
if (urlIntent != null) {
Uri value = urlIntent.getData();
if (value != null) {
List<String> params = value.getPathSegments();
urlParamPnr = params.get(2); // "pnr"
}
}

Categories

Resources