There are a number of workflows, such as requesting location permissions, in which it may be best to navigate the user to the settings screen when they tap on a Call To Action. In order to achieve this we will use a custom deeplink scheme, intercept the deeplink within our app, and instead navigate to the settings screen.
For the purpose of this article, we will define the full URL that should deeplink to the settings page for our App "Temps" to be temps://settings
.
Defining a deeplink scheme
iOS
If you click on your project file in Xcode, and navigate to the Info tab of your app’s target, you can add a deeplink scheme in the URL Types section:

Fill out the URL Schemes String with your desired deeplink (in our example, we will be using "temps").
Android
In your AndroidManifest.xml
, add an intent-filter
to one of your Activities like follows:
<activity> android:name"com.localytics.temps.activity.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> <intent-filter> <data android:scheme="temps" /> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE"/> </intent-filter> </activity>
Fill out the data android:scheme’s value with your desired deeplink (in our example, we will be using "temps").
Intercept the deeplink and navigate to the settings page
iOS
In order to intercept the request we will need to implement a few AppDelegate methods that get called when our app is opened from a deeplink. We will need to double check and ensure that the URL that was triggered was specifically the one designed for opening the OS Settings, and if it was, ask the OS to open the settings.
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { [self handleSettingsLinks:url]; return YES; } - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { [self handleSettingsLinks:url]; return YES; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { [self handleSettingsLinks:url]; return YES; } - (BOOL)handleSettingsLinks:(NSURL *)url { if ([[url path] isEqualToString:@"settings"]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; return YES; } return NO; }
Android
In order to intercept the request we will need to override the onActivityResume
and onNewIntent
methods of the Activity we attached the intent-filter
to in the first step. We will need to double check and ensure that the URL that was triggered was specifically the one designed for opening the OS Settings, and if it was, ask the OS to open the settings.
public class MainActivity extends AppCompatActivity { @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Localytics.onNewIntent(this, intent); Uri data = intent.getData(); if (data != null) { if (data.getScheme().equalsIgnoreCase("temps") && data.getPath().equalsIgnoreCase("settings")){ Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", getPackageName(), null); intent.setData(uri); startActivity(intent); } } } }
Setup an In App with the deeplink
Finally all you need to do is setup an In App with the correct deeplink to navigate to the settings page and you should be good to go!