use of com.applozic.mobicomkit.api.account.register.RegistrationResponse in project Applozic-Android-SDK by AppLozic.
the class ApplozicBridge method gcmRegister.
public static void gcmRegister(Context context, String pushnotificationId) {
if (!MobiComUserPreference.getInstance(context).isRegistered()) {
Log.i("ApplozicBridge", "user is not Registered");
MobiComUserPreference pref = MobiComUserPreference.getInstance(context);
if (!TextUtils.isEmpty(pushnotificationId)) {
pref.setDeviceRegistrationId(pushnotificationId);
}
return;
}
PushNotificationTask pushNotificationTask = null;
PushNotificationTask.TaskListener listener = new PushNotificationTask.TaskListener() {
@Override
public void onSuccess(RegistrationResponse registrationResponse) {
}
@Override
public void onFailure(RegistrationResponse registrationResponse, Exception exception) {
}
};
pushNotificationTask = new PushNotificationTask(pushnotificationId, listener, context);
AlTask.execute(pushNotificationTask);
}
use of com.applozic.mobicomkit.api.account.register.RegistrationResponse in project Applozic-Android-SDK by AppLozic.
the class Applozic method connectUser.
// old api >>>
/**
* Use this method to log-in or register your {@link User}. This must be done before using any other SDK method.
*
* <p>Before calling this method, make sure that {@link User#isValidUserId()} returns <i>true</i>.</p>
*
* <p>If the user (<code>userId</code>) is not present in the servers, a new
* one will be created and registered. Otherwise the existing user will be authenticated and logged in.</p>
*
* <p><i><b>Note:</b>Check if <code>registrationResponse</code> is non-null and {@link RegistrationResponse#isRegistrationSuccess()} is true to confirm a successful login.</i></p>
*
* <p>After a successful login, you'll be able to access:
* <ul>
* <li>{@link MobiComUserPreference#getUserId() your user-id}.</li>
* <li>{@link com.applozic.mobicomkit.contact.AppContactService#getContactById(String) your contact object}.</li>
* <li>Your messages, contacts, channels and other freshly synced data to your local database for your user.</li>
* </ul></p>
*
* <p>Other users will be able to see your status as "online".</p>
*
* <p>Next steps:</p>
* <ol>
* <li>To set up push notifications - {@link #registerForPushNotification(Context, String)}. This is required for receiving messages.</li>
* <li>To send your first message - {@link com.applozic.mobicomkit.api.conversation.MessageBuilder}</li>
* </ol>
*/
public static void connectUser(@NonNull Context context, @NonNull User user, @Nullable AlLoginHandler loginHandler) {
if (isConnected(context)) {
RegistrationResponse registrationResponse = new RegistrationResponse();
registrationResponse.setMessage("User already Logged in");
Contact contact = new ContactDatabase(context).getContactById(MobiComUserPreference.getInstance(context).getUserId());
if (contact != null) {
registrationResponse.setUserId(contact.getUserId());
registrationResponse.setContactNumber(contact.getContactNumber());
registrationResponse.setRoleType(contact.getRoleType());
registrationResponse.setImageLink(contact.getImageURL());
registrationResponse.setDisplayName(contact.getDisplayName());
registrationResponse.setStatusMessage(contact.getStatus());
}
if (loginHandler != null) {
loginHandler.onSuccess(registrationResponse, context);
}
} else {
AlTask.execute(new UserLoginTask(user, loginHandler, context));
}
}
use of com.applozic.mobicomkit.api.account.register.RegistrationResponse in project Applozic-Android-SDK by AppLozic.
the class Applozic method loginUser.
// deprecated code >>>
/**
* @deprecated Use {@link Applozic#connectUser(Context, User)}.
*/
@Deprecated
public static void loginUser(Context context, User user, boolean withLoggedInCheck, AlLoginHandler loginHandler) {
if (withLoggedInCheck && MobiComUserPreference.getInstance(context).isLoggedIn()) {
RegistrationResponse registrationResponse = new RegistrationResponse();
registrationResponse.setMessage("User already Logged in");
loginHandler.onSuccess(registrationResponse, context);
} else {
AlTask.execute(new UserLoginTask(user, loginHandler, context));
}
}
Aggregations