- SDK Version: 41.0.1
- Platforms(Android/iOS/web/all): Android
Hi, I’m facing a problem with expo push notification service. Everything works perfectly but a thing, notification doesn’t wake up the lock screen of android devices. It works on ios.
I’m using the snack from documentation, here’s my code :
NotificationProvider.TS
React.useEffect(() => {
if (!authContext.authState.isConnected) return;
registerForPushNotificationsAsync().then((token) => setExpoPushToken(token));
notificationListener.current = Notifications.addNotificationReceivedListener((notification) => {
setNotification(notification);
});
responseListener.current = Notifications.addNotificationResponseReceivedListener((response) => {
console.log(response);
});
return () => {
Notifications.removeNotificationSubscription(notificationListener.current);
Notifications.removeNotificationSubscription(responseListener.current);
};
}, [authContext.authState.isConnected]);
import Constants from 'expo-constants';
import * as Notifications from 'expo-notifications';
import { Platform } from 'react-native';
import React from 'react';
export async function registerForPushNotificationsAsync() {
let token;
if (Constants.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;
}
token = (await Notifications.getExpoPushTokenAsync()).data;
console.log(token);
} else {
alert('Must use physical device for Push Notifications');
}
if (Platform.OS === 'android') {
await Notifications.setNotificationChannelAsync('Requêtes', {
name: 'Requêtes',
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: '#FF231F7C',
lockscreenVisibility: Notifications.AndroidNotificationVisibility.PUBLIC,
enableLights: true,
});
}
return token;
}
Doesn’t found any solution on internet. Does anyone having faced the same issue ?