onMobileRTCLoginReturn not being called

Description

This is how I setup my SDK

class AppDelegate: UIResponder, UIApplicationDelegate, MobileRTCAuthDelegate {

func setupSDK(sdkKey: String, sdkSecret: String) {
let context = MobileRTCSDKInitContext()
context.domain = “zoom.us
context.enableLog = true

    let sdkInitializedSuccessfully = MobileRTC.shared().initialize(context)
    
    if sdkInitializedSuccessfully == true, let authorizationService = MobileRTC.shared().getAuthService() {
        authorizationService.clientKey = sdkKey
        authorizationService.clientSecret = sdkSecret
        authorizationService.jwtToken = "xxxxxxx"
        authorizationService.delegate = self
        authorizationService.sdkAuth()
    }
}

This is my callback method in AppDelegate.

func onMobileRTCLoginReturn(_ returnValue: Int) {
    switch returnValue {
    case 0:
        print("Successfully logged in")

        // This alerts the ViewController that login was successful.            NotificationCenter.default.post(name: Notification.Name("userLoggedIn"), object: nil)
    case 1002:
        print("Password incorrect")
    default:
        print("Could not log in. Error code: \(returnValue)")
    }
}

This function called when user login

>  func logIn(email: String, password: String) {
>         if let authorizationService = MobileRTC.shared().getAuthService() {
>             authorizationService.login(withEmail: email, password: password, rememberMe: false)
>         }
>     }

Can you please check this and let me know. Is it possible that my JWT token is expired that’s why login method is not called?

Which iOS Client SDK version?
I’m using 5.2.42037.1112 version

Smartphone (please complete the following information):

  • Device: [e.g. iPhone 12]
  • OS: [e.g. iOS 14.4]

Hey @officialmakkar,

Thanks for using the dev forum!

The issue is that you are supplying both a client key/secret and a JWT. The SDK only needs a JWT, please remove those two lines.

Thanks!
Michael

Even after removing those two line I face same issue.

Hi @officialmakkar,

Can you please confirm whether or not you are receiving the onMobileRTCAuthReturn callback before trying to log in? If so, what is the returnValue from that callback?

Thanks!

Perviously I used the device only SDK at that time onMobileRTCAuthReturn is called but later I used SDK for mobile and Simulator and I run the app on simulator but onMobileRTCAuthReturn is not fired.

No I run the app in actual device with iPhone X and I found onMobileRTCAuthReturn is not fire. Is it possible that if JWT is incorrect that reason onMobileRTCAuthReturn not trigger?

This is How i’m creating the JWT

import SwiftyJWT

let alg = JWTAlgorithm.hs256(“secret”)
let headerWithKeyId = JWTHeader.init(keyId: “”)

    var payload = JWTPayload()
    payload.customFields = ["app_key": EncodableValue(value: "jzf3f2-"),
                            "version": EncodableValue(value: 1),
                            "user_identity": EncodableValue(value: Global.user!.emp_zoom_user_id),
                            "iat": EncodableValue(value: NSDate().timeIntervalSince1970),
                            "exp":EncodableValue(value: NSDate().timeIntervalSince1970 + 5000),
                            "tpc":EncodableValue(value: "12")]
    
    let jwtWithKeyId = try? JWT.init(payload: payload, algorithm: alg, header: headerWithKeyId)

    print(jwtWithKeyId)

Can you please help me.

Hey @officialmakkar,

I am suspecting that the JWT payload may be generated incorrectly. To verify this, can you create a JWT through JWT.io and hardcode it into your application to see if this above code is causing the issue? Instructions for doing so can be found here: "auth sdk failed" when running zoom sdk demo - #7 by Michael_Condon

Thanks!
Michael

1 Like

Thanks for the reply I fixed the issue. Great support.

1 Like

Hey @officialmakkar,

Awesome! I am happy to hear :slight_smile:
Please let me know if there are any other issues.

Thanks!
Michael

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.