phone_email_auth 0.0.6 copy "phone_email_auth: ^0.0.6" to clipboard
phone_email_auth: ^0.0.6 copied to clipboard

Flutter plugin for authenticating phone number. This plugin send OTP to mobile numbers and verify it and return verified mobile number and user's first and last name.

phone_email_auth plugin #

Flutter plugin for authenticating phone number. this plugin send OTP to mobile numbers and verify it and return verified mobile number to user.

Getting Started #

Install

    dependencies:
    phone_email_auth: ^0.0.6

Import

    import 'package:phone_email_auth/phone_email_auth.dart';

Initialize phone email plugin

    PhoneEmail.initializeApp(clientId: 'YOUR_CLIENT_ID');

Note: #

clientId : Set clientId which you obtained from Profile Details section of Admin Dashboard of Phone Email.

Add Phone Email Login Button #

    
    child: PhoneLoginButton(
    borderRadius: 8,
    buttonColor: Colors.teal,
    label: 'Sign in with Phone',
    onSuccess: (String accessToken, String jwtToken) {
      if (accessToken.isNotEmpty) {
        setState(() {
          userAccessToken = accessToken;
          jwtUserToken = jwtToken;
          hasUserLogin = true;
        });
      }
    },
    )

The PhoneLoginButton will return the accessToken and jwtToken, which are necessary for obtaining the verified phone number.

Get Verified phone number: #

Once you've obtained the accessToken, get verified phone number by calling the getUserInfo() function. Use the following code snippet to retrieve the verified phone number and user details.

        PhoneEmail.getUserInfo(
            accessToken: userAccessToken,
            clientId: phoneEmail.clientId,
            onSuccess: (userData) {
                setState(() {
                phoneEmailUserModel = userData;
                var countryCode = phoneEmailUserModel?.countryCode;
                var phoneNumber = phoneEmailUserModel?.phoneNumber;
                var firstName = phoneEmailUserModel?.firstName;
                var lastName = phoneEmailUserModel?.lastName;
    
                // Use this verified phone number to register user and create your session
    
                });
            },
        );

Display Email Alert: #

Integrate an email alert icon on your screen for a successfully authenticated user. Use the following code snippet to fetch the unread email count and display the email icon.

        floatingActionButton: hasUserLogin
            ? EmailAlertButton(
            jwtToken: jwtUserToken,
            ) : const Offstage(),
        );
2
likes
140
points
214
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for authenticating phone number. This plugin send OTP to mobile numbers and verify it and return verified mobile number and user's first and last name.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dart_jsonwebtoken, flutter, flutter_inappwebview, flutter_udid, http, shared_preferences

More

Packages that depend on phone_email_auth