Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(FIXED) "[messaging/unknown] The operation couldn’t be completed". #2657

Closed
4 of 10 tasks
AdamGold opened this issue Sep 29, 2019 · 194 comments · Fixed by #3017
Closed
4 of 10 tasks

(FIXED) "[messaging/unknown] The operation couldn’t be completed". #2657

AdamGold opened this issue Sep 29, 2019 · 194 comments · Fixed by #3017
Assignees
Labels
platform: ios plugin: messaging FCM only - ( messaging() ) - do not use for Notifications

Comments

@AdamGold
Copy link

AdamGold commented Sep 29, 2019

EDIT (by @Salakar): This is fixed since the 6.4.0 release.


Issue

Cloud messaging gives an error when using messaging().getToken after upgrading to V6 and RN 0.61:

Error: [messaging/unknown] The operation couldn’t be completed. (com.firebase.iid error 1001.)
NativeFirebaseError: [messaging/unknown] The operation couldn’t be completed. (com.firebase.iid error 1001.)
    at FirebaseMessagingModule.getToken (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:122099:28)
    at _callee2$ (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:117856:74)
    at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29289:19)
    at Generator.invoke [as _invoke] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29464:24)
    at Generator.prototype.(anonymous function) [as next] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29332:23)
    at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29289:19)
    at invoke (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29365:22)
    at http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29395:13
    at tryCallTwo (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3223:7

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'Glitz' do
  use_native_modules!
# use_frameworks!

  # Pods for Glitz
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for Glitz
  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  pod 'react-native-ble-plx', :path => '../node_modules/react-native-ble-plx'
  pod 'react-native-ble-plx-swift', :path => '../node_modules/react-native-ble-plx'
  pod 'react-native-radar', :path => '../node_modules/react-native-radar'

  # https://stackoverflow.com/questions/42021796/react-native-xcode-project-product-archive-fails-with-duplicate-symbols-for-arch
  # https://github.com/facebook/react-native/issues/12814


  pod 'react-native-ble-plx', :path => '../node_modules/react-native-ble-plx'

  pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      targets_to_ignore = %w(React yoga)
      
      if targets_to_ignore.include? target.name
        target.remove_from_project
      end

      if target.name == 'react-native-ble-plx-swift'
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '4.2'
        end
      end
      if target.name == 'react-native-config'
        phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
        phase.shell_script = "cd ../../"\
                            " && RNC_ROOT=./node_modules/react-native-config/"\
                            " && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
                            " && export BUILD_DIR=$RNC_ROOT/ios/ReactNativeConfig"\
                            " && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"

        target.build_phases << phase
        target.build_phases.move(phase,0)
      end
    end
  end

end


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

---

Environment

Click To Expand

react-native info output:

  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 27.0.3, 28.0.2, 28.0.3
      System Images: android-26 | Intel x86 Atom_64, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.2 AI-181.5540.7.32.5056338
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.1 => 0.61.1 
  npmGlobalPackages:
    create-react-native-app: 2.0.2
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
    react-native-version: 3.1.0
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 6.0.0
  • Firebase module(s) you're using that has the issue:
    • Cloud messaging
  • Are you using TypeScript?
    • N

@dwyery
Copy link

dwyery commented Sep 29, 2019

I am also getting this error on RN 0.61.1 when I call await messaging().getToken();.

@cjishnu
Copy link

cjishnu commented Oct 1, 2019

For iOS, add the following in Info.plist:
"FirebaseAppDelegateProxyEnabled" set as "NO"
After this, I got the fcmToken.

@Ehesp
Copy link
Member

Ehesp commented Oct 1, 2019

cc @Salakar

@Salakar
Copy link
Member

Salakar commented Oct 1, 2019

Does this only happen on RN61? Is it fine on 60?

@dwyery
Copy link

dwyery commented Oct 1, 2019

I just rolled back to a previous release branch for my app which had RN60.5 and I still get this error. cjishnu solution did not work me.

Is there maybe some logic missing that we have to do now before calling this function? I have read the docs but can't see anything obvious.

I managed to get a workaround for now. Since I am on iOS >= 12 requestPermission() no longer prompts the user:

On iOS, messaging permission must be requested by the current application before messages can be received or sent.

On iOS >= 12, the app will be granted Provisional Authorization, and will resolve true. The user will be able to receive FCM payloads and Notifications immediately; but notifications will be displayed silently. The user, through Notification Center, then has the option of upgrading your apps notifications to no longer be silent.

So I use the PushNotificationIOS.requestPermissions() from the @react-native-community/push-notification-ios library to do this. Once the register event has been triggered I can successfully call messaging().getToken() which returns a token and no error.

@iamcxa
Copy link

iamcxa commented Oct 2, 2019

For iOS, add the following in Info.plist:
"FirebaseAppDelegateProxyEnabled" set as "NO"
After this, I got the fcmToken.

I tried this workaround but got no lucky :( still got no token but error 1001

@iamcxa
Copy link

iamcxa commented Oct 2, 2019

I just rolled back to a previous release branch for my app which had RN60.5 and I still get this error. cjishnu solution did not work me.

Is there maybe some logic missing that we have to do now before calling this function? I have read the docs but can't see anything obvious.

I managed to get a workaround for now. Since I am on iOS >= 12 requestPermission() no longer prompts the user:

On iOS, messaging permission must be requested by the current application before messages can be received or sent.

On iOS >= 12, the app will be granted Provisional Authorization, and will resolve true. The user will be able to receive FCM payloads and Notifications immediately; but notifications will be displayed silently. The user, through Notification Center, then has the option of upgrading your apps notifications to no longer be silent.

So I use the PushNotificationIOS.requestPermissions() from the @react-native-community/push-notification-ios library to do this. Once the register event has been triggered I can successfully call messaging().getToken() which returns a token and no error.

I can confirm this is a temporary workaround for now.

@AdamGold
Copy link
Author

AdamGold commented Oct 3, 2019

I just rolled back to a previous release branch for my app which had RN60.5 and I still get this error. cjishnu solution did not work me.

Is there maybe some logic missing that we have to do now before calling this function? I have read the docs but can't see anything obvious.

I managed to get a workaround for now. Since I am on iOS >= 12 requestPermission() no longer prompts the user:

On iOS, messaging permission must be requested by the current application before messages can be received or sent.

On iOS >= 12, the app will be granted Provisional Authorization, and will resolve true. The user will be able to receive FCM payloads and Notifications immediately; but notifications will be displayed silently. The user, through Notification Center, then has the option of upgrading your apps notifications to no longer be silent.

So I use the PushNotificationIOS.requestPermissions() from the @react-native-community/push-notification-ios library to do this. Once the register event has been triggered I can successfully call messaging().getToken() which returns a token and no error.

Does not work for me - register event is not getting triggered. It stops the error from showing up though.. because getToken is not getting called.

@dwyery
Copy link

dwyery commented Oct 3, 2019

@AdamGold have you added the required methods to your AppDelegate.m file?

Finally, to enable support for notification and register events you need to augment your AppDelegate.

These methods can be found on the README on the repo.

@AdamGold
Copy link
Author

AdamGold commented Oct 3, 2019

@dwyery Yes, I have.

@mikehardy
Copy link
Collaborator

react-native-permissions is also pretty good...anyone tried that?

@a-ryazanov
Copy link

react-native-permissions is also pretty good...anyone tried that?

Yes, I can confirm that using react-native-permissions is a workaround for now.

@leuchtdiode
Copy link

leuchtdiode commented Oct 4, 2019

I'm doing the following with react-native-permissions:

await requestNotifications(['alert', 'badge', 'sound']);
const instanceId = await iid().get();
const registrationToken = await messaging().getToken();

I'm getting the error the first time I run this code although the notification prompt is popping up and I'm confirming it. The second time (after reload) it's working.

@AdamGold
Copy link
Author

AdamGold commented Oct 6, 2019

I'm still getting an error after calling requestNotifications with react-native-permissions.

@Salakar Salakar added plugin: messaging FCM only - ( messaging() ) - do not use for Notifications platform: ios help: needs-triage Issue needs additional investigation/triaging. labels Oct 7, 2019
@oskaryil
Copy link

oskaryil commented Oct 7, 2019

I think what worked for me was using react-native-permissions to check and ask for notification permissions on iOS. I think it also helps to test this out on a physical device as simulators can't receive notifications.

@LukePenkava
Copy link

@oskaryil Were you able to get the token in the simulator ?

This produces error when trying to get the token:

  Permissions.requestNotifications(['alert', 'sound']).then(({ status, settings }) => {
            console.log(status);
            console.log(settings);

            firebase.messaging().getToken()
                .then(token => {
                    console.log(token);
                })
        })

It was working fine getting the token in simulator before upgrading firebase.

@LukePenkava
Copy link

LukePenkava commented Oct 8, 2019

Using Xcode11 I was able to get it somewhat working on the device ( ios 13.1.2 ). When i use requestNotifications and get the permissions, first time the getToken is called i get the error

Error: [messaging/unknown] The operation couldn’t be completed. (com.firebase.iid error 1001.)

second time i click the button ( call the function to getToken ) it works and i get the token. Thats of course not ideal solution in any case, but at least it is somewhat working on the device. Any idea why it has to be triggered twice ?

Edit:
It seems that using the old solution on the device is working, just getting errors in the sim

 firebase.messaging().requestPermission()
                        .then((value) => {
                            firebase.messaging().getToken()
                                .then(token => {
                                    console.log(token);
                                })
                         })

Edit:
So it seems a bit random, i have to call it twice again to get token correctly even with the firebase.messaging().getToken()

Edit:
Also it seems to work fine on iOS 10 test device for me, so its probably related to iOS 13 more than anything else.

@leuchtdiode
Copy link

leuchtdiode commented Oct 8, 2019

Actually I'm not sure whether I tested on a simulator (Xcode 11 / iOS 13) or my physical device 4 days ago (see my comment). However it looks like the error is not popping up on my iPhone 6 with iOS 12.4.2.

My code is:

let registrationToken = null;

const result = await requestNotifications(['alert', 'badge']);

if (result.status === RESULTS.GRANTED)
{
	try
	{
		registrationToken = await messaging().getToken();
	}
	catch
	{
		console.log("Could not get registration token");
	}
}

@LukePenkava
Copy link

LukePenkava commented Oct 8, 2019

@leuchtdiode Yeah, i am pretty sure based on all the testing i did that its related to iOS 13 rather than to RNFirebase V6 or RN 0.61. It seems to be working fine on older iOS versions with both firebase.messaging().getToken() and React-Native-Permissions. Could work on V5 and iOS 13 tho, i did not test that.

@SamMatthewsIsACommonName
Copy link
Contributor

We're trying to investigate a bit in relation to this and ios 13:
firebase/firebase-ios-sdk#4011

@mikehardy
Copy link
Collaborator

That last comment is fascinating - could be unexpected behavior needing underlying SDK docs and maybe a mention in docs here - seems like it would affect v5 and v6 if you have default data collection disabled firebase/firebase-ios-sdk#4011 (comment)

@mikehardy
Copy link
Collaborator

and (linked off from there) possibly of interest https://onesignal.com/blog/ios-13-introduces-4-breaking-changes-to-notifications/

@SamMatthewsIsACommonName
Copy link
Contributor

SamMatthewsIsACommonName commented Oct 8, 2019

Well for what it's worth we didn't actively set any value in the info.plist (we don't have that field) so not sure if the default is off? Going to try a few combinations

Edit: still getting the error in ios 13 with FirebaseDataCollectionDefaultEnabled: YES in info.plist

Edit 2: As others said, second time loading it works. Very strange

@Salakar Salakar changed the title "[messaging/unknown] The operation couldn’t be completed". (FIXED) "[messaging/unknown] The operation couldn’t be completed". Apr 3, 2020
@quachdev
Copy link

quachdev commented Apr 3, 2020

@Salakar thanks for the update. Will there be a patch fix for v5 as well? I am currently on v5 and unable to upgrade currently.

@mikehardy
Copy link
Collaborator

There is no way to backport all the fixes for messaging that went in to v6 to v5, they were massive and v5 has been on life support only for months and months. I understand (as a v5 user currently) that the prospect of upgrading something so fundamental is daunting, but it's about time. Notifee has iOS support in testing now (developed in conjunction with those fixes) and there are other libraries as well

@kyytiPetteri
Copy link

kyytiPetteri commented Apr 7, 2020

Just updated to 6.4.0 Now getting the following error on Android:

NativeFirebaseError: [messaging/unknown] FIS_AUTH_ERROR

Coming from await getToken() method

@toytonic
Copy link

toytonic commented Apr 8, 2020

Hello,
after upgrading to v6.4.0, I can't send messages to iOS devices from Firebase.

I use the following to retrieve a token (same statement as with v5.x):
const token = await firebase.messaging().getToken()

When trying to send a remote message from Firebase, it gives me this error:
Auth error from APNS or Web Push Service

Any ideas? Do I have to set a scope or authorizedEntity?

@ssuchanowski
Copy link

did you do firebase.messaging().requestPermission() and firebase.messaging().registerDeviceForRemoteMessages()?

@toytonic
Copy link

toytonic commented Apr 8, 2020

Yes. In my case it is used for data messages only in a (weak) 2Factor Auth Scenario:

await firebase.messaging().registerDeviceForRemoteMessages()
await firebase.messaging().requestPermission()
const token = await firebase.messaging().getToken()
...

Requesting permissions shouldn't even be necessary for my use case. All the above functions work. But the serverside complains when trying to send a message and no message handler gets fired. That's why I'm wondering if in v5 a different default scope or authorizedEntity was used.

@ssuchanowski
Copy link

By data messages you mean silent push?

As far as I understand you should call the firebase.messaging().requestPermission() first.

Regarding the message handler - share the code that is not working for you.

What I do usually when testing is getting apns token and try to send push witha different service - you can easily find a tool or python script that would do that. Then you can rule out at least push notification setup on iOS part.

@toytonic
Copy link

toytonic commented Apr 8, 2020

Exactly, it's a silent push. The message handle part should not be concerned as the error happens on the server side.
Nevertheless here you go:

useEffect(() => {
    async function registerNotification() {
      await firebase.messaging().registerDeviceForRemoteMessages()
      await firebase.messaging().requestPermission()

      const token = await firebase.messaging().getToken()
      ...
    }

    const cleanup = firebase.messaging().onMessage(message => {
      const { data } = message
      ...
    })

    registerNotification()

    return cleanup
}, [])

@ssuchanowski
Copy link

Did you try to send push notification without firebase?

If error is on server side are you sure you should be looking here for resolution? How do you send the push? Via firebase cloud messaging platform directly or API?

@toytonic
Copy link

toytonic commented Apr 9, 2020

Well, it's working with v5.x and it stops working when trying to upgrade to v6.4. For sure the error could be in my implementation, but so far I could not find a working solution. Thanks a lot for your help, I'll get back if I get more insights

@rizkiandrianto

This comment has been minimized.

@DmitryKvant
Copy link

Same for me on server -

Auth error from APNS or Web Push Service

@aledustet
Copy link

aledustet commented May 13, 2020

I am running on v 6.7.1 and I also get the:

Error: [messaging/unknown] SERVICE_NOT_AVAILABLE
NativeFirebaseError: [messaging/unknown] SERVICE_NOT_AVAILABLE

As soon as I try to get the token on Android.

@thinhtrh
Copy link

thinhtrh commented Jun 3, 2020

Same issue on "@react-native-firebase/app": "^7.1.4", "@react-native-firebase/messaging": "^7.1.3", "react-native": "0.62.2". Any solution to fix it?

@Buwaneka-Sumanasekara
Copy link

Check your internet connection. May be little help

@RaulCorreia
Copy link

I am running on v 7.2.0 for app and v 7.1.4 for messaging and I also get the:

Error: [messaging/unknown] SERVICE_NOT_AVAILABLE
NativeFirebaseError: [messaging/unknown] SERVICE_NOT_AVAILABLE

As soon as I try to get the token on Android.

@luvnish19
Copy link

I am still having this issue in iOS. Please help if there is any escape?

@RaulCorreia
Copy link

I downgrade for app v 6.7.1 and messaging v 6.7.1 and work

@luvnish19
Copy link

@RaulCorreia I am already using 6.7.1 and it was working fine by last week but today when I ran again. It alerts me same error.
Any other solution or escape?

@RaulCorreia
Copy link

@RaulCorreia I am already using 6.7.1 and it was working fine by last week but today when I ran again. It alerts me same error.
Any other solution or escape?

What I did was, generate another google-services.json in the firebase panel and use version 6.7.1 and it worked again.
I don't know if what I did really changed anything, but it was the only thing I did.

@BoluwajiDavids
Copy link

@RaulCorreia I am having the same issue with the latest version of @react-native-firebase/app and @react-native-firebase/messaging. When I try to get device token with messaging.getToken(), it returns this error:
Error: [messaging/unknown] SERVICE_NOT_AVAILABLE
NativeFirebaseError: [messaging/unknown] SERVICE_NOT_AVAILABLE

Has anyone solved a similar problem recently? @luvnish19 how did you solve the problem on your end?
Any help will be appreciated here

@luvnish19
Copy link

@BoluwajiDavids
I am using version 6.7.1 and I removed and add .p8 file on console.developers.google.com fixed my issue.

@BoluwajiDavids
Copy link

Thank you @luvnish19
I am building for android.
I have downgraded to 6.7.1 for both @react-native-firebase/app and @react-native-firebase/messaging previously but still had the same problem. I don't know if the p8 file you mentioned applies to android too?

@ghost
Copy link

ghost commented Aug 19, 2020

@RaulCorreia I am already using 6.7.1 and it was working fine by last week but today when I ran again. It alerts me same error.
Any other solution or escape?

What I did was, generate another google-services.json in the firebase panel and use version 6.7.1 and it worked again.
I don't know if what I did really changed anything, but it was the only thing I did.

thanks alot it worked for me. changed only google services.json file

@andersonaddo andersonaddo unpinned this issue Aug 19, 2020
@IamMasterWayne
Copy link

"react-native": "0.61.5",
"@react-native-firebase/messaging": "^6.3.4"

  await firebase.messaging().registerForRemoteNotifications();
   const granted = firebase.messaging().requestPermission();

Facing this issue:
[messaging/unknown] The operation couldn’t be completed. (com.firebase.iid error 1001.)

@arlovip
Copy link

arlovip commented Sep 15, 2020

The same issue +1

@invertase invertase locked as resolved and limited conversation to collaborators Sep 15, 2020
@mikehardy mikehardy removed the Workflow: Needs Review Pending feedback or review from a maintainer. label Nov 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: ios plugin: messaging FCM only - ( messaging() ) - do not use for Notifications
Projects
None yet