Android Integration
On this page you'll find integration guides for Android platforms. Use the tabs to pick your framework.
- React Native
- Expo
React Native Integration
You will get the redirectUrl after the Consent Creation API call.
redirectUrl: https://staging.indiaconsent.com/consent?cr_id=c8ab306d-0a53-4af1-9f3c-c4662df39500
React Native Basic Implementation
import { useEffect } from 'react';
import { Linking, View } from 'react-native';
export default function ConsentScreen() {
useEffect(() => {
const CONSENT_URL = redirectUrl + '&mobile_app=true&app_scheme=myapp';
Linking.openURL(CONSENT_URL).catch(err =>
console.error('Failed to open URL:', err)
);
}, []);
return <View />;
}
React Native Deep Link Handling
Configure AndroidManifest.xml:
<activity
android:name=".ConsentActivity"
android:exported="true">
<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="myapp"
android:host="consent"
android:path="/callback" />
</intent-filter>
</activity>
Listen for callbacks:
import { useEffect } from 'react';
import { Linking, View, Text } from 'react-native';
export default function ConsentDeepLinkHandler() {
useEffect(() => {
const handleDeepLink = ({ url }) => {
// URL comes from the deep link when app is opened via custom scheme (e.g., myapp://consent/callback?status=success)
const isConsentCallback = url && url.includes('myapp://consent/callback');
if (isConsentCallback) {
const params = new URLSearchParams(url.split('?')[1]);
const status = params.get('status');
console.log('Consent completed:', { status });
}
};
const subscription = Linking.addEventListener('url', handleDeepLink);
Linking.getInitialURL().then((url) => {
if (url) {
handleDeepLink({ url });
}
});
return () => subscription?.remove();
}, []);
return (
<View>
<Text>Hanle consent deep links here</Text>
</View>
);
}
Expo Integration
You will get the redirectUrl after the Consent Creation API call.
redirectUrl: https://staging.indiaconsent.com/consent?cr_id=c8ab306d-0a53-4af1-9f3c-c4662df39500
Expo Basic Implementation
import { useEffect } from 'react';
import * as Linking from 'expo-linking';
import { View } from 'react-native';
export default function ConsentScreen() {
useEffect(() => {
const CONSENT_URL = redirectUrl + '&mobile_app=true&app_scheme=myapp';
Linking.openURL(CONSENT_URL).catch(err =>
console.error('Failed to open URL:', err)
);
}, []);
return <View />;
}
Expo Deep Link Handling
Configure in app.json:
{
"expo": {
"scheme": "myapp",
"plugins": [
[
"expo-url-handler",
{
"scheme": "myapp"
}
]
]
}
}
Listen for callbacks:
import { useEffect } from 'react';
import * as Linking from 'expo-linking';
import { View, Text } from 'react-native';
export default function ConsentDeepLinkHandler() {
useEffect(() => {
const handleDeepLink = ({ url }) => {
// URL comes from the deep link when app is opened via custom scheme (e.g., myapp://consent/callback?status=granted)
const isConsentCallback = url && url.includes('myapp://consent/callback');
if (isConsentCallback) {
const params = new URLSearchParams(url.split('?')[1]);
const status = params.get('status');
console.log('Consent completed:', { status });
}
};
const subscription = Linking.addEventListener('url', handleDeepLink);
Linking.getInitialURL().then((url) => {
if (url) {
handleDeepLink({ url });
}
});
return () => subscription?.remove();
}, []);
return (
<View>
<Text>Listening for consent deep links...</Text>
</View>
);
}