initialize method

void initialize()

Implementation

void initialize(){
  platform.setMethodCallHandler((call) async{
    dynamic result;
    try{
      switch(call.method){
        case CHANNEL_INIT: result = _initializeModule(call: call); break;
        case CHANNEL_SIGN_UP: result = signUp(call: call); break;
        case CHANNEL_VERIFY_EMAIL: result = verifyEmail(call: call); break;
        case CHANNEL_RESEND_EMAIL_VERIFICATION_CODE: result = resendEmailVerificationCode(call: call); break;
        case CHANNEL_LOGIN: result = login(call: call); break;
        case CHANNEL_LOGIN_WITH_GOOGLE: result = loginWithGoogle(call: call); break;
        case CHANNEL_LOGIN_WITH_APPLE: result = loginWithApple(call: call); break;
        case CHANNEL_RENEW_ACCESS_TOKEN: result = renewAccessToken(call: call); break;
        case CHANNEL_CHANGE_PASSWORD: result = changePassword(call: call); break;
        case CHANNEL_FORGOT_PASSWORD: result = forgotPassword(call: call); break;
        case CHANNEL_GET_ACCESS_TOKEN: result = getAccessToken(call: call); break;
        case CHANNEL_GET_REFRESH_TOKEN: result = getRefreshToken(call: call); break;
        case CHANNEL_GET_USER_ID: result = getUserId(call: call); break;
        case CHANNEL_LOGOUT: result = logout(call: call); break;
        case CHANNEL_IS_LOGGED_IN: result = isLoggedIn(call: call); break;
        case CHANNEL_IS_TOKEN_EXPIRED: result = isTokenExpired(call: call); break;
        case CHANNEL_LOG_USER_ACTIVITY: result = logUserActivity(call: call); break;
        case CHANNEL_UPDATE_USER_INFO: result = updateUserInfo(call: call); break;
        case CHANNEL_UPDATE_LAST_ACTIVE: result = updateLastActive(call: call); break;
        default: return null;
      }
      platform.invokeMethod(call.method, jsonEncode(await result));
    }catch(e, s){
      platform.invokeMethod(call.method, jsonEncode({
        "success": false,
        "message": "Failed to process request with error : $e"
      }));
    }
    return true;
  });
}