Twilio voice call not working in react native - react-native

I am trying to using react-native-twilio-programmable-voice library for use Twilio voice call. I implemented library and setup code from server end I received access token and used this in below code:
initTwilio = async () => {
const token = await this.getAuthToken();
if (Platform.OS === 'android') {
await this.getMicrophonePermission();
}
await TwilioVoice.initWithToken(token);
TwilioVoice.addEventListener('deviceReady', () => {
console.log("device Ready");
this.setState({ twilioInited: true });
});
if (Platform.OS === 'ios') { //required for ios
TwilioVoice.configureCallKit({
appName: 'ReactNativeTwilioExampleApp',
});
}
};
makeCall = () => TwilioVoice.connect({ To: '+919929294578' });
When I press I didn't get "device ready" in output and nothing happened if anyone did that please advice so I can complete...Thanks!

Related

DeviceNotRegistered: "ExponentPushToken[***]" is not a registered push notification recipient

I'm trying to implement expo push notifications on react native app built with expo !
I did everything mentioned on their docs ! i'm getting the token successfully but when i try sending a push notification to that token using their api or the tool they provide i get this error
DeviceNotRegistered: "ExponentPushToken[***]" is not a registered push notification recipient
This is how i'm getting the token !
export const useNotifications = () => {
const registerForPushNotificationsAsync = async () => {
if (Device.isDevice) {
const { status: existingStatus } =
await Notifications.getPermissionsAsync();
let finalStatus = existingStatus;
if (existingStatus !== "granted") {
const { status } = await Notifications.requestPermissionsAsync();
finalStatus = status;
}
if (finalStatus !== "granted") {
alert("Failed to get push token for push notification!");
return;
}
const token = (await Notifications.getExpoPushTokenAsync()).data;
console.log("TOKEN------------", token);
alert(token);
} else {
alert("Must use physical device for Push Notifications");
}
if (Platform.OS === "android") {
Notifications.setNotificationChannelAsync("default", {
name: "default",
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: "#FF231F7C",
});
}
};
const handleNotification = (notification = Notifications.Notification) => {
// could be useful if you want to display your own toast message
// could also make a server call to refresh data in other part of the app
};
// This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)
const handleNotificationResponse = (
response = Notifications.NotificationResponse
) => {
const data = ({ url } = response.notification.request.content.data);
if (data?.url) Linking.openURL(data.url);
};
return {
registerForPushNotificationsAsync,
handleNotification,
handleNotificationResponse,
};
};
useEffect(() => {
registerForPushNotificationsAsync();
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: true,
}),
});
const responseListener =
Notifications.addNotificationResponseReceivedListener(
handleNotificationResponse
);
return () => {
if (responseListener) {
Notifications.removeNotificationSubscription(responseListener);
}
};
}, []);
i run the eas build eas build -p android --profile preview so i can test it on a real device since push notifications works only on real devices and after that i pushed the cloud messaging server key that i got from my firebase project with this command expo push:android:upload --api-key <your-token-here>
As i said i successfully get the token but the i get the error when trying to send the notification!
am i missing a step or something ?
I tried run the build on two devices and both not working !

How to use react native track player to stream live audio

Hello I have a streaming service, (it is an online radio) that I need to stream in my app, the url it is the following
https://cast.uncuartocomunicacion.com:8020/live
I have been using react native sound player to stream it but I had issues with android's performance. So I switched to react native track player, but I haven't been able of playing the streaming service.
the following it is the code I have been using.
const start = async () => {
await TrackPlayer.setupPlayer();
await TrackPlayer.add({
id: 'trackI1',
url: 'https://cast.uncuartocomunicacion.com:8020/live',
title: 'Area deportiva',
artist: 'Area deportiva',
artwork: {
uri:
'https://pbs.twimg.com/profile_images/1480935488232075270/STi9FaUo_400x400.jpg',
},
});
TrackPlayer.updateOptions({
stopWithApp: false,
});
setLoading(false);
};
useEffect(() => {
//let isMounted = true;
//Alert.alert(audioUrl);
//getUrl();
//SoundPlayer.loadUrl('https://cast.uncuartocomunicacion.com:8020/live');
/*TrackPlayer.setupPlayer()
.then(() => {
setLoading(false);
})
.catch((e) => {
setLoading(false);
});*/
start()
.then()
.catch((e) => {
Alert.alert('e ' + JSON.stringify(e));
});
}, []);
const handlePlayPause = () => {
console.warn('asa is playing ', isPlaying);
/* */
try {
/* !isPlaying ? SoundPlayer.resume() : SoundPlayer.pause();*/
if (!isPlaying) {
Alert.alert('enre aquiu ');
TrackPlayer.play()
.then((r) => {
Alert.alert('then play' + JSON.stringify(r));
})
.catch((e) => {
Alert.alert('e ' + JSON.stringify(e));
});
} else {
TrackPlayer.pause().then((r) => console.log(r));
}
} catch (e) {}
setIsPlaying(!isPlaying);
};
I hope someone can help me!!!
For some reason when you play audio with SSL and use another port (8020) it doesn't work, but you can try using http and add
android:usesCleartextTraffic="true"
in AndroidManifest

Error: An error occurred while trying to log in to Facebook expo-facebook android issue

I am trying to implement Facebook login in a simple expo app but on the android expo client, it is not working. Following version, I am using.
"expo-facebook": "~12.0.3",
Method code
const handleAuth = async () => {
try {
let options = null;
if (Platform.OS === "android") {
options = {appId: "xxxxxxxxxxxxxx"};
} else {
options = {
appId: "xxxxxxxxxxxxxx",
version: "v9.0",
appName: "xxxxxxxx",
};
}
let res = await Facebook.initializeAsync(options);
console.log("[init res]", res);
const {type, token, expirationDate, permissions, declinedPermissions} =
await Facebook.logInWithReadPermissionsAsync({
permissions: ["public_profile"],
});
console.log("[type]", type);
console.log("[token]", token);
if (type === "success") {
// SENDING THE TOKEN TO FIREBASE TO HANDLE AUTH
const credential = app.auth.FacebookAuthProvider.credential(token);
app
.auth()
.signInWithCredential(credential)
.then((user) => {
// All the details about user are in here returned from firebase
console.log("Logged in successfully", user);
dispatch(saveUser(user));
navigation.replace("App");
})
.catch((error) => {
console.log("Error occurred ", error);
});
} else {
// type === 'cancel'
}
} catch (res) {
console.log("[res]", res);
// alert(`Facebook Login Error: ${res}`);
}
};
Another error i am facing is FacebookAuthProvider is not available in firebase
firebase": "8.10.0"
I have tried the following ways.
app.auth.FacebookAuthProvider
Or
app.auth().FacebookAuthProvider
but both are not working.
Please help if anyone integrated facbook login in. "expo": "~44.0.0"

Why EXPO standalone app shows url_invalid?

i am working with Expo project using stripe react native , its work fine in local, publish but not working as expected in standalone app,
here i use stripe for payment and when i enter card info its returns erorr 400
400 Error
POST /v1/payment_intents/pi_3JSeHwSJwGztdZyL1BuqSJQq/confirm
"return_url": "myappname:///--/://safepay",
url_invalid - return_url Not a valid URL
here is my code :
<StripeProvider
publishableKey="xyz"
urlScheme={Linking.createURL('') + '/--/'}
setUrlSchemeOnAndroid = {true}
.............................../>
const handleDeepLink = useCallback(
async (url: string | null) => {
if (url && url.includes('safepay')) {
await handleURLCallback(url);
console.log('url',url)
navigation.navigate('Checkout', { url });
}
},
[navigation, handleURLCallback]
);
useEffect(() => {
const getUrlAsync = async () => {
const initialUrl = await Linking.getInitialURL();
handleDeepLink(initialUrl);
console.log('initialUrl',initialUrl)
};
const urlCallback = (event: { url: string }) => {
handleDeepLink(event.url);
};
getUrlAsync();
Linking.addEventListener('url', urlCallback);
return () => Linking.removeEventListener('url', urlCallback);
}, [handleDeepLink]);
how to achive deep link and how to resole this ?
Using: Standalone app, Expo 42, stripe-react-native :0.1.4

react-native-linkdin-login is not working in ios?

I am using react-native-linkdin-login library to support linkding sigin in my application.It is working properly in android but in iOS it always ask to download an application rather than application already exist in device and redirect to the APP store. When I open and login to linkdin account, I can't come back to my react-native application, with user profile details.
Give me any suggestion as soon as possible.
async componentWillMount() {
LinkedinLogin.init(
[
'r_emailaddress',
'r_basicprofile'
]
);
}
async handleLinkedinLogin(){
LinkedinLogin.login().then((user) => {
alert("linkdin");
this.setState({ user : user });
this.getUserProfile();
}).catch((e) => {
var err = JSON.parse(e.description);
alert("ERROR: " + err.errorMessage);
alert('Error', e);
});
return true;
}
getUserProfile(user) {
LinkedinLogin.getProfile().then((data) => {
const userdata = Object.assign({}, this.state.user, data);
this.setState({ user: userdata });
const Email = userdata.emailAddress;
const Fullname = userdata.firstName+' '+userdata.lastName;
const SocialAppId = userdata.id;
const SignupType = 'Linkedin';
alert("Please wait....")
this.socialLogin(Fullname,Email,'null',SignupType);
}).catch((e) => {
alert(e);
});
}