Search in sources :

Example 21 with MobiComUserPreference

use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.

the class MobiComMessageService method createEmptyMessage.

public void createEmptyMessage(Contact contact) {
    Message sms = new Message();
    MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(context);
    sms.setContactIds(contact.getFormattedContactNumber());
    sms.setTo(contact.getContactNumber());
    sms.setCreatedAtTime(0L);
    sms.setStoreOnDevice(Boolean.TRUE);
    sms.setSendToDevice(Boolean.FALSE);
    sms.setType(Message.MessageType.MT_OUTBOX.getValue());
    sms.setDeviceKeyString(userPreferences.getDeviceKeyString());
    sms.setSource(Message.Source.MT_MOBILE_APP.getValue());
    messageDatabaseService.createMessage(sms);
}
Also used : PersonalizedMessage(com.applozic.mobicommons.personalization.PersonalizedMessage) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference)

Example 22 with MobiComUserPreference

use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.

the class MobiComMessageService method syncMessageForMetadataUpdate.

public synchronized void syncMessageForMetadataUpdate() {
    final MobiComUserPreference userpref = MobiComUserPreference.getInstance(context);
    SyncMessageFeed syncMessageFeed = messageClientService.getMessageFeed(userpref.getLastSyncTimeForMetadataUpdate(), true);
    Utils.printLog(context, TAG, "\nStarting syncMessages for metadata update for lastSyncTime: " + userpref.getLastSyncTimeForMetadataUpdate());
    if (syncMessageFeed != null && syncMessageFeed.getMessages() != null) {
        userpref.setLastSyncTimeForMetadataUpdate(String.valueOf(syncMessageFeed.getLastSyncTime()));
        List<Message> messageList = syncMessageFeed.getMessages();
        for (final Message message : messageList) {
            if (message != null) {
                new MessageDatabaseService(context).updateMessageMetadata(message.getKeyString(), message.getMetadata());
                BroadcastService.updateMessageMetadata(context, message.getKeyString(), BroadcastService.INTENT_ACTIONS.MESSAGE_METADATA_UPDATE.toString());
            }
        }
    }
}
Also used : PersonalizedMessage(com.applozic.mobicommons.personalization.PersonalizedMessage) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference) SyncMessageFeed(com.applozic.mobicomkit.sync.SyncMessageFeed) MessageDatabaseService(com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)

Example 23 with MobiComUserPreference

use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.

the class MobiComMessageService method sendCustomMessage.

public void sendCustomMessage(Message message) {
    MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(context);
    message.setStoreOnDevice(Boolean.TRUE);
    message.setSendToDevice(Boolean.FALSE);
    message.setType(Message.MessageType.MT_OUTBOX.getValue());
    message.setContentType(Message.ContentType.CUSTOM.getValue());
    message.setDeviceKeyString(userPreferences.getDeviceKeyString());
    message.setSource(Message.Source.MT_MOBILE_APP.getValue());
    conversationService.sendMessage(message, messageIntentServiceClass);
}
Also used : MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference)

Example 24 with MobiComUserPreference

use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.

the class MobiComMessageService method addWelcomeMessage.

public void addWelcomeMessage(String content) {
    Message message = new Message();
    MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(context);
    message.setContactIds(new Support(context).getSupportNumber());
    message.setTo(new Support(context).getSupportNumber());
    message.setMessage(content);
    message.setStoreOnDevice(Boolean.TRUE);
    message.setSendToDevice(Boolean.FALSE);
    message.setType(Message.MessageType.MT_INBOX.getValue());
    message.setDeviceKeyString(userPreferences.getDeviceKeyString());
    message.setSource(Message.Source.MT_MOBILE_APP.getValue());
    conversationService.sendMessage(message, messageIntentServiceClass);
}
Also used : PersonalizedMessage(com.applozic.mobicommons.personalization.PersonalizedMessage) Support(com.applozic.mobicommons.commons.core.utils.Support) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference)

Example 25 with MobiComUserPreference

use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference 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);
    pushNotificationTask.execute((Void) null);
}
Also used : PushNotificationTask(com.applozic.mobicomkit.api.account.user.PushNotificationTask) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference) TaskListener(com.applozic.mobicomkit.api.account.user.UserLoginTask.TaskListener) RegistrationResponse(com.applozic.mobicomkit.api.account.register.RegistrationResponse)

Aggregations

MobiComUserPreference (com.applozic.mobicomkit.api.account.user.MobiComUserPreference)33 Message (com.applozic.mobicomkit.api.conversation.Message)8 ArrayList (java.util.ArrayList)6 Intent (android.content.Intent)5 Gson (com.google.gson.Gson)5 Contact (com.applozic.mobicommons.people.contact.Contact)4 PersonalizedMessage (com.applozic.mobicommons.personalization.PersonalizedMessage)4 User (com.applozic.mobicomkit.api.account.user.User)3 Channel (com.applozic.mobicommons.people.channel.Channel)3 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 NonNull (android.support.annotation.NonNull)2 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)2 MobiComConversationService (com.applozic.mobicomkit.api.conversation.MobiComConversationService)2 InvalidApplicationException (com.applozic.mobicomkit.exception.InvalidApplicationException)2 UnAuthoriseException (com.applozic.mobicomkit.exception.UnAuthoriseException)2 MessageResponse (com.applozic.mobicomkit.feed.MessageResponse)2 SyncMessageFeed (com.applozic.mobicomkit.sync.SyncMessageFeed)2 JsonParser (com.google.gson.JsonParser)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2