use of org.infobip.mobile.messaging.mobile.MobileMessagingError in project mobile-messaging-sdk-android by infobip.
the class AndroidBroadcasterTest method test_should_send_error.
@Test
public void test_should_send_error() throws Exception {
// Given
MobileMessagingError error = new MobileMessagingError("SomeCode", "SomeMessage");
// When
broadcastSender.error(error);
// Then
Mockito.verify(contextMock, Mockito.times(1)).sendBroadcast(intentArgumentCaptor.capture());
Intent intent = intentArgumentCaptor.getValue();
assertEquals(Event.API_COMMUNICATION_ERROR.getKey(), intent.getAction());
MobileMessagingError errorAfter = (MobileMessagingError) intent.getSerializableExtra(BroadcastParameter.EXTRA_EXCEPTION);
assertJEquals(error, errorAfter);
}
use of org.infobip.mobile.messaging.mobile.MobileMessagingError in project mobile-messaging-sdk-android by infobip.
the class MobileMessagingBroadcastReceiver method onApiCommunicationError.
void onApiCommunicationError(Context context, Intent intent) {
MobileMessagingError mobileMessagingError = (MobileMessagingError) intent.getSerializableExtra(EXTRA_EXCEPTION);
String errorDescription = mobileMessagingError != null ? mobileMessagingError.getMessage() : context.getString(R.string.error_api_comm_unknown) + "\n";
PreferenceManager.getDefaultSharedPreferences(context).edit().putString(ApplicationPreferences.LAST_API_COMMUNICATION_ERROR, errorDescription).apply();
}
use of org.infobip.mobile.messaging.mobile.MobileMessagingError in project mobile-messaging-sdk-android by infobip.
the class AndroidGeoBroadcasterTest method test_should_send_error.
@Test
public void test_should_send_error() throws Exception {
// Given
MobileMessagingError error = new MobileMessagingError("SomeCode", "SomeMessage");
// When
broadcastSender.error(error);
// Then
Mockito.verify(contextMock, Mockito.times(1)).sendBroadcast(intentArgumentCaptor.capture());
Intent intent = intentArgumentCaptor.getValue();
assertEquals(Event.API_COMMUNICATION_ERROR.getKey(), intent.getAction());
MobileMessagingError errorAfter = (MobileMessagingError) intent.getSerializableExtra(BroadcastParameter.EXTRA_EXCEPTION);
assertJEquals(error, errorAfter);
}
use of org.infobip.mobile.messaging.mobile.MobileMessagingError in project mobile-messaging-sdk-android by infobip.
the class MainActivity method onMSISDNPreferenceChanged.
private void onMSISDNPreferenceChanged(SharedPreferences sharedPreferences) {
Long msisdn = null;
try {
if (sharedPreferences.contains(ApplicationPreferences.MSISDN)) {
msisdn = Long.parseLong(sharedPreferences.getString(ApplicationPreferences.MSISDN, "0"));
if (msisdn <= 0) {
throw new IllegalArgumentException();
}
}
} catch (Exception e) {
showToast(R.string.toast_message_userdata_invalid);
return;
}
if (msisdn != null) {
UserData userData = new UserData();
userData.setMsisdn(msisdn.toString());
MobileMessaging.getInstance(this).syncUserData(userData, new MobileMessaging.ResultListener<UserData>() {
@Override
public void onResult(UserData result) {
Log.v(TAG, "User data sync complete: " + result);
}
@Override
public void onError(MobileMessagingError e) {
Log.e(TAG, String.format(Locale.getDefault(), "User data sync error message: %s, code: %s" + e.getMessage(), e.getCode()));
}
});
}
}
Aggregations