I am on Android and I want to use DeepLink to open a specific screen using react navigation.
Here is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.samtbook">
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme"
android:supportsRtl="false"
android:usesCleartextTraffic="true"
>
<activity
android:launchMode="singleTask"
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<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:scheme="http" android:host="samtbook.me"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="API_KET"/> // HIDDEN
</application>
and here is the link I use:
http://samtbook.me/test/
and I registered my deepLink like this:
componentDidMount() {
Linking.addEventListener('url', this.handleOpenURL);
}
componentWillUnmount() {
Linking.removeEventListener('url', this.handleOpenURL);
}
handleOpenURL = (event) => {
this.navigate(event.url);
};
navigate = (url) => {
this.props.navigation.navigate('TestScreen');
};
The poblem is When the app is not running in the background(Means dead)
I click over the link and it opens the app but not navigate to intended screen
but when the app is running in background it navigates
Thanks in advance
Use react navigation deeplinking mentioned in doc:
https://reactnavigation.org/docs/en/deep-linking.html
Http scheme is detected as a web url just change your scheme to a custom scheme for example "myapp" and change your url to myapp://samtbook.me/test/ good luck!
Related
I've a React-Native app with the following code (here App.js, the app entry point) that manages deep link on Android.
Linking.getInitialURL().then((deepLinkUrl) => {
if (deepLinkUrl) {
manageDeepLink(deepLinkUrl);
} else {
Navigation.startSingleScreenApp('rootScreen');
}
});
The problem here is that getInitialURL is called every time I launch my app, from both deep link or normally, and everytime it contains deepLinkUrl parameter empty.
I've registered in AndroidManifest my intent as follows:
<application
android:name=".MainApplication"
android:allowBackup="true"
android:launchMode="singleTask"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustResize">
<!-- deeplink -->
<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:scheme="myapp" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
UPDATE
I'm using react-native navigation to register screens, if this can e useful.
It seems it doesn't work if you register listener too soon in the app lifecycle (ex. directly in some .js file, so it's executed when app is loaded).
If you move it into componentDidMount() on the root component everything works fine.
componentDidMount() {
Linking.addEventListener('url', event => {
console.warn('URL', event.url)
})
Linking.getInitialURL().then(url => {
console.warn('INITIAL', url)
})
}
Because you added android:launchMode="singleTask" to AndroidManifest.xml. Please modify it to android:launchMode="singleTop", then your problem will be gone.
I've followed the steps in the android documentation Here to implement linking in my application. I dont really need any fancy parameter passing, all I want is when the user clicks a link on the browser that my app opens. All I did was modify my AndroidManifest. Here is the relevant part
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="u2player" android:host="open.my.app" />
</intent-filter>
</activity>
I am using react-native-navigation and trying to browse from either the chrome browser or the native browser to any of u2player:// u2player://open.my.app u2player://open.my.app/ doesn't work. I have also binded the url event from the Linking module but nothing works. I restarted, uninstalled, etc.
Help appreciated
Try using branch. It solves most of the problem that you are facing and it also has a very clean documentation. Please go through and let me know if you have any issues
I am developing an application which is replacement of Google Now.
My application is already being launched when swiped up.
I need to replace icon of the ring?
Some application in market can do this and there is a feature in Cyanogenmod already. So it is possible, but how?
Thanks
EDIT :
After a few restarts it shows icon properly. I may need find a way to force it. Maybe i could restart SystemUI but how ? :)
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true">
<activity
android:name=".contact.ContactActivity"
android:label="#string/title_activity_contact"
android:excludeFromRecents="true"
android:theme="#style/Theme.AppCompat.NoActionBar.Transparent">
<meta-data
android:name="com.android.systemui.action_assist_icon"
android:resource="#drawable/ic_assist"/>
<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.ASSIST"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
Try this:
<intent-filter>
<action android:name="android.intent.action.ASSIST"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="com.android.systemui.action_assist_icon" android:resource="#drawable/launch_button" />
I am trying to set up a mobile website that opens my mobile app when a link is clicked in the Android browser. To accomplish this task, I added an intent filter to AndroidManifest.xml, as seen in the code below:
<activity android:name=".MyAppActivity" android:label="#string/app_name" android:theme="#style/Theme.Titanium" android:configChanges="keyboardHidden|orientation" android:alwaysRetainTaskState="true" android:launchMode="singleInstance">
<intent-filter>
<data android:scheme="myapp" android:host="app"/>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
The link itself in the browser works great, and I'm easily able to gather parameters when the app is first opened using Ti.Android.currentActivity. The problem comes when the app is already open, but a user clicks the link to open it from within the mobile browser. When my app opens, instead of resuming where I left off before, I simply see the splashscreen. This goes both ways: If I opened the app first from the mobile browser, then tried to resume it later from the Android homescreen or app drawer, I only see the splash screen. Per tips I saw on other places of the internet, I tried adding the code below to AndroidManifest.xml (as seen above):
android:alwaysRetainTaskState="true" android:launchMode="singleInstance"
This however, appears to have no effect on anything, and the same problem persists. What am I missing here? Any help would be greatly appreciated.
The way i have done was like this
<android xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18"/>
<manifest android:installLocation="preferExternal"
android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application android:label="App Name" android:largeHeap="true">
<activity
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="#string/app_name"
android:launchMode="singleTop"
android:name=".mainActivity" android:theme="#style/Theme.Titanium">
<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:scheme="schemaname"/>
</intent-filter>
</activity>
</application>
</manifest>
</android>
and its working fine for me . for Android 4.XX
I have an android application with three activities: Loading, Main, Credits.
But when I try to run and look into the emulator, I have three icons: Loading, Main, Credits.
How can I just have a single Application name? And where do I set it?
Set in android manifest file in application level.
android:label="#string/app_name"
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Loading"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Main" />
<activity android:name=".Credits" />
In your AndroidManifest.xml, you just need to set <intent-filter> for only one Activity other Activities don't need this tag.