I have been trying to integrate twilio-voice-react-native with react-native-call-keep to make outgoing calls through the app. It is working fine with the below code on Android but giving Failed to initialize PushKit device token
on iOS.
const voice = new Voice();
const initializeCallKeep = async () => {
try {
RNCallKeep.setup({
ios: {
appName: "App Name",
},
android: {
alertTitle: "Permissions required",
alertDescription:
"This application needs to access your phone accounts",
cancelButton: "Cancel",
additionalPermissions: [],
okButton: "ok",
},
});
RNCallKeep.setAvailable(true);
} catch (err) {
console.error("initializeCallKeep error>>>>>", err);
}
};
React.useEffect(() => {
initializeCallKeep();
}, []);
const callAction = async () => {
const token = await getAccessToken();
await voice.register(token);
const twiMLParams = {
params: {
guestName: firstName + " " + lastName,
},
};
const callUUID = getGUID();
const call = await voice.connect(token, twiMLParams);
RNCallKeep.startCall(callUUID, "", phoneNumber);
}
After doing some research and going through multiple articles for some time, I was able to find a solution to fix the iOS issue.
You need to first call
await voice.initializePushRegistry();
before doingvoice.register();
.Here's the updated code:
For more - https://github.com/twilio/twilio-voice-react-native/blob/main/docs/applications-own-pushkit-handler.md