react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
745 stars 285 forks source link

Notification Permission Pop up is displaying on app launch #115

Open MaganAnkur opened 4 years ago

MaganAnkur commented 4 years ago

For some reason the popup asking permission for the push notifications is showing automatically when the app is opened for the first time even if I am configuring Push Notification later in the app.

Please let me know the way how can I stop auto ask permission on app launch.

Below is my componentDidMount code in entry file:

`componentDidMount() { AppState.addEventListener('change', this.appStateDidChange) Orientation.lockToPortrait() Orientation.addDeviceOrientationListener(this.orientationDidChange) this.unsubscribeAuthStateChangeListener = firebase .auth() .onAuthStateChanged(this.authStateDidChange) this.unsubscribeNetInfoStatListener = NetInfo.addEventListener( this.props.setNetStat )

this.fetchData()
this.initBranch()

if (this.props.isLoggedIn && this.props.isFirebaseAuthenticated) {
  if (this.props.hasValidCards) {
    Orientation.unlockAllOrientations()
  }

  navigate(Routes.Main)
  this.props.getCards()
}

this.updateLocationPermissionState()

//Repositioning this to after create account notification prompt
PushNotification.configure({
  onRegister: token => {
    LeanplumManager.setUserPushToken(token.token)
  },
  senderId: Config.FIREBASE_CLOUD_MESSAGING_SENDER_ID,
  requestPermissions: false,
  popInitialNotification: false
})

}`

kasterlod commented 4 years ago

It's because of UNUserNotificationCenter part in didFinishLaunchingWithOptions (AppDelegate.m)

naajaw commented 3 years ago

@kasterlod okay, makes sense, but can it be put somewhere else so we can call requestPermissions() at a specific time from the react layer?

dzpt commented 3 years ago

How do i lately ask for permission ?

lucianobracco-geojam commented 1 year ago

Where can it be put in order to delay the requestPermissions()

It's because of UNUserNotificationCenter part in didFinishLaunchingWithOptions (AppDelegate.m)