简体   繁体   中英

Firebase Auth Phone not working when using for production

So I have successfully set up Firebase Messaging and push notification works great. However, when I add Firebase Auth for phone, only sandbox works. Below is my code:

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    [[FIRAuth auth] setAPNSToken:deviceToken type:FIRAuthAPNSTokenTypeSandbox];
}

When using FIRAuthAPNSTokenTypeSandbox, [[FIRPhoneAuthProvider provider] verifyPhoneNumber:phoneNumber...] will work. However, when I use FIRAuthAPNSTokenTypeProd, I will get internal server error. I have uploaded both Development and Production certificates on my Firebase console, and push notification works great when users download my app through Test Flight.

My question is why is this the case, and how would I be able to fix it? I am afraid if I keep using sandbox, some future users will not be able to receive the SMS messages, but at the same time, production doesn't work.

Another question I have is, will I be able to localize and customize my SMS messages? I will be sending these codes to users in multiple countries.

If anyone knows the answer that would be great! Thanks in advance!

Answer for your First Question :

  1. When I add Firebase Auth for phone, only sandbox works.

Please have in mind, about the type of certificate you are using while sharing the build,

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

    // If you are using the development certificate you have to use this,
        [[FIRAuth auth] setAPNSToken:deviceToken type:FIRAuthAPNSTokenTypeSandbox];

    // If you are using distribution certificate you should use this
        [[FIRAuth auth] setAPNSToken:deviceToken type:FIRAuthAPNSTokenTypeProd];

    // If you want Firebase to automatically detect the type use this.
        [[FIRAuth auth] setAPNSToken:deviceToken type:FIRAuthAPNSTokenTypeUnknown];

    }
  1. a) Localize : Yes you can.

[[FIRAuth auth] useAppLanguage]; Ref: Firebase Phone Number Auth Document

  b) Customize my SMS messages : No you can't. 
  As this may abuse the user experience. Got clarification from Firebase as "Those templates can't be edited, sorry. There is a good deal of concern that this service could be abused and used for spam and other bad practices."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM