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);
}
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());
}
}
}
}
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);
}
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);
}
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);
}
Aggregations