react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
749 stars 286 forks source link

onRegister does not get fired on real iPhone 7 | 1.0.6 and 1.0.7 #94

Closed Psiiirus closed 4 years ago

Psiiirus commented 4 years ago

Bug

I'm trying to get this lib working on iOS 13.1.3 / iPhone 7 but the onRegister event never gets fired. It is working on other devices so I'm quite confused...unf. I can't upgrade my iOS version because a downgrade is disallowed by apple.

Environment info

push-notification-ios: 1.0.6, 1.0.7 & 1.1.0 I doubled checked all the required iOS code changes and they look fine.

For android I'm using @react-native-firebase/app": "^6.3.4

react-native info output:

System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 694.04 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.6.0 - /usr/local/bin/node
    Yarn: 1.19.1 - ~/.yarn/bin/yarn
    npm: 6.14.4 - ~/.npm-global/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 23.0.1, 23.0.2, 25.0.1, 25.0.3, 26.0.1, 26.0.3, 27.0.0, 27.0.3, 28.0.3
      System Images: android-23 | Intel x86 Atom_64, android-25 | Google Play Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64
  IDEs:
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5

Steps To Reproduce

add:


  PushNotificationIOS.requestPermissions().then((data)=>{
    console.log('PushNotificationIOS::requestPermissions', { ...data });
  });

  PushNotificationIOS.addEventListener('register', (data) => {
    console.warn('_____PushNotificationIOS::register', { ...data });
  });

  PushNotificationIOS.addEventListener('registrationError', (data) => {
    console.warn('_____PushNotificationIOS::registrationError', { ...data });
  });

Describe what you expected to happen:

1.requestPermissions gets fired

  1. register & registrationError never gets fired
Psiiirus commented 4 years ago

I just tried to get the example project of this repo to work but it seems not to be functional either for 1.1.0 it even seems it hasn't been updated to 1.1.0.

hannojg commented 4 years ago

Isn't the newest version 1.1.1?

Psiiirus commented 4 years ago

@hannojg well as i started this ticket 1.1.0 was the latest

Psiiirus commented 4 years ago

Just found something really interesting inside the apple docs!

https://developer.apple.com/library/archive/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG21

No Delegate Callbacks When the first push-capable app is installed, iOS or OS X attempts to establish a persistent network connection to the push service that will be shared by all push-capable apps on the system. If neither delegate callback application:didRegisterForRemoteNotificationsWithDeviceToken: nor application:didFailToRegisterForRemoteNotificationsWithError: is called, that means that this connection has not yet been established.

So after adding a sim card into my testing device – which was already connected by wifi – it seems to ping the apple services again and it startet working. Means the following event handler ever gets triggered event the native-code callbacks will not receive any error:

  PushNotificationIOS.addEventListener('register', (data) => {
    console.warn('_____PushNotificationIOS::register', { ...data });
  });

  PushNotificationIOS.addEventListener('registrationError', (data) => {
    console.warn('_____PushNotificationIOS::registrationError', { ...data });
  });
Psiiirus commented 4 years ago

FYI: still struggling with 1.1.0/1 but i think this is a different problem because it's native code changed.

@tahourj thanks for all your time and effort yesterday!

ZishanK commented 4 years ago

@Psiiirus hi, can you please share that how you fixed "onRegister does not get fired on real iPhone 7"?