-
Notifications
You must be signed in to change notification settings - Fork 183
Open
Description
I want to play audio notification after OneSignal notification is received. Here's my code (on App.tsx):
const handleForegroundNotification = (event: any) => {
console.log('Foreground Notification:', event);
event.notification.display();
setTimeout(() => {
if (AppState.currentState === 'active') {
Tts.getInitStatus().then(() => {
if (lng == 'id'){
Tts.setDefaultLanguage('id');
Tts.speak("Pembayaran diterima. " + Terbilang(12500) + " rupiah");
}
else {
Tts.setDefaultLanguage('en-US');
Tts.speak("Payment accepted. " + numberToWords(12500) + " rupiah");
}
}).catch(err => {
console.error('TTS init error', err);
});
} else {
console.log('App not in foreground, skipping TTS');
}
}, 1000);
};
On Android 15 simulator, after OneSignal notification is received, audio is played (perhaps after adding android.permission.FOREGROUND_SERVICE and android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK permissions).
But on iOS 18.3 simulator, no audio is played at all after OneSignal notification is arrived.
Found this on the log:
TTS init error [Error: Function not implemented]
I'm using RN 0.71.0 and RN TTS 4.1.1
Metadata
Metadata
Assignees
Labels
No labels