Skip to content

Commit

Permalink
Merge pull request #31 from virresh/push_notifs
Browse files Browse the repository at this point in the history
Push notifs
  • Loading branch information
Taejas authored Nov 5, 2019
2 parents c462fee + eca6f11 commit 8dd9517
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
sendNotification(remoteMessage.getNotification().getBody(), remoteMessage.getNotification().getTitle());
}

// Also if you intend on generating your own notifications as a result of a received FCM
Expand Down Expand Up @@ -130,7 +131,7 @@ public static void sendRegistrationToServer(String token) {
*
* @param messageBody FCM message body received.
*/
private void sendNotification(String messageBody) {
private void sendNotification(String messageBody, String messageTitle) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
Expand All @@ -141,7 +142,7 @@ private void sendNotification(String messageBody) {
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.drawable.app_logo)
.setContentTitle(getString(R.string.fcm_message))
.setContentTitle(messageTitle)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_mentor_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
android:background="@color/colorPrimary"
android:textColor="@color/white"
android:layout_gravity="center"
android:drawableLeft="@drawable/ic_date_range_black_24dp"
android:drawableLeft="@drawable/ic_access_time_black_24dp"
android:drawablePadding="8dp"
android:text="Select Time" />

Expand Down

0 comments on commit 8dd9517

Please sign in to comment.