iOS Integration
On this page you'll find integration guides for iOS platforms. Use the tabs to pick your framework.
- React Native
- Expo
React Native Integration
You will get the Consent URL after the Consent Creation API call.
Consent URL: https://www.indiaconsent.com/consent?cr_id=...&mobile_app=true&app_scheme=myapp
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 Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.example.myapp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
</dict>
</array>
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=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>
);
}
Expo Integration
You will get the Consent URL after the Consent Creation API call.
Consent URL: https://www.indiaconsent.com/consent?cr_id=...&mobile_app=true&app_scheme=myapp
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>
);
}