use of com.kickstarter.models.pushdata.GCM in project android-oss by kickstarter.
the class DebugPushNotificationsView method simulateProjectLaunchButtonClick.
@OnClick(R.id.simulate_project_launch_button)
public void simulateProjectLaunchButtonClick() {
final GCM gcm = GCM.builder().title("Want to be the first backer?").alert("Taylor Moore just launched a project!").build();
final Activity activity = Activity.builder().category(com.kickstarter.models.Activity.CATEGORY_LAUNCH).id(5).projectId(PROJECT_ID).build();
final PushNotificationEnvelope envelope = PushNotificationEnvelope.builder().activity(activity).gcm(gcm).build();
pushNotifications.add(envelope);
}
use of com.kickstarter.models.pushdata.GCM in project android-oss by kickstarter.
the class DebugPushNotificationsView method simulateBurstClick.
@OnClick(R.id.simulate_burst_button)
public void simulateBurstClick() {
final PushNotificationEnvelope baseEnvelope = projectSuccessEnvelope();
for (int i = 0; i < 100; i++) {
// Create a different signature for each push notification
final GCM gcm = baseEnvelope.gcm().toBuilder().alert(Integer.toString(i)).build();
pushNotifications.add(baseEnvelope.toBuilder().gcm(gcm).build());
}
}
use of com.kickstarter.models.pushdata.GCM in project android-oss by kickstarter.
the class DebugPushNotificationsView method projectSuccessEnvelope.
@NonNull
private PushNotificationEnvelope projectSuccessEnvelope() {
final GCM gcm = GCM.builder().title("Time to celebrate!").alert("SKULL GRAPHIC TEE has been successfully funded.").build();
final Activity activity = Activity.builder().category(com.kickstarter.models.Activity.CATEGORY_SUCCESS).id(6).projectId(PROJECT_ID).projectPhoto(PROJECT_PHOTO).build();
return PushNotificationEnvelope.builder().activity(activity).gcm(gcm).build();
}
use of com.kickstarter.models.pushdata.GCM in project android-oss by kickstarter.
the class MessageService method onMessageReceived.
/**
* Called when a message is received from Firebase.
* - If the message comes from braze it will be handle on:
* - @see RemotePushClientType#handleRemoteMessages(android.content.Context, com.google.firebase.messaging.RemoteMessage)
* - If the message is from Kickstarter it will be process here
*
* @param remoteMessage Object containing message information.
*/
@Override
public void onMessageReceived(final RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
final Boolean isBrazeMessage = this.remotePushClientType.handleRemoteMessages(this, remoteMessage);
if (!isBrazeMessage) {
final String senderId = getString(R.string.gcm_defaultSenderId);
final String from = remoteMessage.getFrom();
if (!TextUtils.equals(from, senderId)) {
Timber.e("Received a message from %s, expecting %s", from, senderId);
return;
}
final Map<String, String> data = remoteMessage.getData();
final PushNotificationEnvelope envelope = PushNotificationEnvelope.builder().activity(this.gson.fromJson(data.get("activity"), Activity.class)).erroredPledge(this.gson.fromJson(data.get("errored_pledge"), PushNotificationEnvelope.ErroredPledge.class)).gcm(this.gson.fromJson(data.get("gcm"), GCM.class)).message(this.gson.fromJson(data.get("message"), PushNotificationEnvelope.Message.class)).project(this.gson.fromJson(data.get("project"), PushNotificationEnvelope.Project.class)).survey(this.gson.fromJson(data.get("survey"), PushNotificationEnvelope.Survey.class)).build();
if (envelope == null) {
Timber.e("Cannot parse message, malformed or unexpected data: %s", data.toString());
return;
}
Timber.d("Received message: %s", envelope.toString());
this.pushNotifications.add(envelope);
}
}
use of com.kickstarter.models.pushdata.GCM in project android-oss by kickstarter.
the class PushNotifications method displayNotificationFromProjectReminder.
private void displayNotificationFromProjectReminder(@NonNull final PushNotificationEnvelope envelope) {
final GCM gcm = envelope.gcm();
final PushNotificationEnvelope.Project project = envelope.project();
if (project == null) {
return;
}
final Intent projectIntent = projectIntent(envelope, ObjectUtils.toString(project.id()));
final Notification notification = notificationBuilder(gcm.title(), gcm.alert(), CHANNEL_PROJECT_REMINDER).setContentIntent(projectContentIntent(envelope, projectIntent)).setLargeIcon(fetchBitmap(project.photo(), false)).build();
notificationManager().notify(envelope.signature(), notification);
}
Aggregations