alpha._404_
alpha._404_

Reputation: 11

IOS app crashing when notification permission denied

we have published the app to testflight , and when opening the app ,when notification permission is denied app is crashing and app is working perfectly when notification permission is accepted

i am using expo eas framework expo sdk:46 react-native:'0.70.5'

actually i am handling this scenario , of denying the notification permission

const status=await Notifications.getPermissionsAsync();
        let finalStatus =status['status'];
        console.log(status);
        let existingStatus=finalStatus;
        console.log(finalStatus);
        
        //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!');
           token.data =  'Failed'+ Math.round((Math.pow(36, 20 + 1) - Math.random() * Math.pow(36, 20))).toString(36).slice(1);
          console.log(token);
        }
        else
        {
          token = await Notifications.getExpoPushTokenAsync({experienceId:'@username/slug',}); 
          console.log(token);
          await AsyncStorage.setItem('expopushtoken',token.data);
        }

and everything is fine in development build

, onething i was not sure whether it is causing issue is, i was using 'notifications Response Received Listener irresective whether we have notification permission or not'

Notifications.addNotificationResponseReceivedListener(this._handleNotificationResponse);

btw,the above is not causing issue in ios development builds or any android builds,

how to resolve the issue , can someone help me?

i have tried to replicate the issue in development build, which has no use

Upvotes: 1

Views: 324

Answers (0)

Related Questions