EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 445 forks source link

phone login error #457

Open lawrencetaur opened 7 years ago

lawrencetaur commented 7 years ago

I've followed all instructions as per the documentation for cloud messaging and phone authentication but when I try to login, I get the following error.

[Firebase/Analytics][I-ACS023012] Firebase Analytics enabled [Firebase/Analytics][I-ACS032010] Cannot send request for Search Ad campaign attribution. Error: Error Domain=ADClientErrorDomain Code=0 "Unable to retrieve attribution details" UserInfo={NSLocalizedDescription=Unable to retrieve attribution details} [Firebase/Analytics][I-ACS032005] Search Ad Campaign attribution alarm is already scheduled CONSOLE LOG file:///app/login/login.component.js:26:24: login error: If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method.

EddyVerbruggen commented 7 years ago

I don't see much useful info in that log really. I do wonder if you have enabled (and configured) AdMob. And is this on a simulator? If so, please also try a real device.

lawrencetaur commented 7 years ago

I've enabled admob in the config but not really using it. This is on a real iphone 4s.

lawrencetaur commented 7 years ago

The error im trying to highlight is If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method.

EddyVerbruggen commented 7 years ago

You can ignore that (it's an internal msg from the Firebase SDK about push notifications which can be ignored but not suppressed).

Please remove AdMob from your firebase config json file and re-add the iOS platform.

Other than that there's not really an error related to phone login..

lawrencetaur commented 7 years ago

I have modified the firebase config json file as below:

{ "using_ios": true, "using_android": true, "remote_config": false, "messaging": true, "crash_reporting": false, "storage": false, "facebook_auth": false, "google_auth": true, "admob": false, "invites": false }

And also re-added the IOS platform,but still facing the same error on firebase phone login:

6:24:27 PM - Compilation complete. Watching for file changes. [Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled [Firebase/Analytics][I-ACS032010] Cannot send request for Search Ad campaign attribution. Error: Error Domain=ADClientErrorDomain Code=0 "Unable to retrieve attribution details" UserInfo={NSLocalizedDescription=Unable to retrieve attribution details} [Firebase/Analytics][I-ACS032005] Search Ad Campaign attribution alarm is already scheduled CONSOLE LOG file:///app/login/login.component.js:26:24: login error: If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method.

EddyVerbruggen commented 7 years ago

Like I said that error is useless to me.

When exactly do you get this error, and can you share a project that reproduces it?

lawrencetaur commented 7 years ago

Here is the link to the project https://drive.google.com/file/d/0B-Q9QNgTEoLEYkxPdFpLVDhkdDA/view?usp=sharing

I get this error when I run the following. Also, not getting test push notifications, it shows up in console in foreground(only after reopening the app) but not in background. Could this be the issue?

firebase.login({ type: firebase.LoginType.PHONE, phoneOptions: { phoneNumber: '+919986993442', verificationPrompt: "The received verification code" // default "Verification code" } }).then( function (result) { console.log("res" + JSON.stringify(result)); }, function (errorMessage) { console.log("login error: " + errorMessage); } );

greg-nagy commented 7 years ago

I am way no expert here but I had this issue when I didn't set up my firebase ios integration properly. After deleting and recreateing with the correct app id prefix, bundle id and cloud messaging with the correct p8 apn auth key everything was fine. It's relatively easy to find out. If you see the dialog pop up AND get the sms then the problem is in the code somewhere. If you do not get the sms then the firebasse ios apn setup is wrong.

It took me way longer then I would like to admit to find it out though :)

TimMun commented 6 years ago

I am also having a similar problem. I don't think I have an issue with configs, since when I create a new Swift app (non-nativescript) and integrate Firebase SDK using Google's instructions, using the same project and bundle identifier, the SMS does come through to my phone.

Trying the same using nativescript-firebase results in the "If app delegate swizzling is disabled..." error (there are no other errors) and the SMS doesn't come thru. When using the Firebase Notification Console, I am able to receive push notifications in my nativescript app, so FCM and APNs does appear to be config'ed correctly.

Any ideas on where to start digging? I'm using an iPhone 6 running 11.1.2. In nativescript-plugin-firebase, the error seems to be appear at line 1197 in firebase.ios.ts:

FIRPhoneAuthProvider.provider().verifyPhoneNumberCompletion(arg.phoneOptions.phoneNumber, (verificationID: string, error: NSError) => {
          if (error) {
            reject(error.localizedDescription);
            return;
          }

But I'm not sure how to dig any further than that. These are the packages I have installed:

{
    "using_ios": true,
    "using_android": true,
    "remote_config": true,
    "messaging": true,
    "crash_reporting": true,
    "storage": true,
    "facebook_auth": false,
    "google_auth": false,
    "admob": true,
    "invites": false
}

Other than that, my code is pretty much barebones, virtually a copy-paste from the instructions. Email login works fine, it's just the phone auth that fails. Since the Swift version does receive the SMS I doubt I have an issue with my configs in the Firebase project, but I'm all ears...

sitefinitysteve commented 6 years ago

Can you try to edit your GoogleService-Info.plist and disable adwords (assuming you arent using it)

    <key>IS_ADS_ENABLED</key>
    <false/>
    <key>IS_ANALYTICS_ENABLED</key>
    <true/>

This resolved my error (was the same as yours above)

TimMun commented 6 years ago

Thanks for the suggestion; tried that, but unfortunately it didn't work.

My current thinking is that somehow the silent push notification isn't getting forwarded to FIRAuth, which is why the SMS doesn't come thru. If I set a breakpoint in UNUserNotificationCenterDelegateImpl.prototype.userNotificationCenterWillPresentNotificationWithCompletionHandler, the breakpoint never trips. Maybe it's an iOS 11 bug, but the delegate method isn't being called. (I'm testing this with app in the foreground)

TimMun commented 6 years ago

I finally got it to work. I had to move the firebase.init() somewhere after app launch, as referenced by this issue. I just put it in a viewmodel, and the init is triggered by a button for now. The missing piece was that I still had to put require("nativescript-plugin-firebase"); inside app.js, before application.start(). Hope this helps someone else.

anuragd7 commented 6 years ago

Thanks @sitefinitysteve . Your suggestion worked. I was getting really frustrated. Any idea why this happens?