-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notifications for request made and accepted
* Notification stuff initialised -Node.Js part added -Notification added to DB on request sent and request accepted, with different 'type' value * Some bugfixes -changed onSuccessListener to onCompleteListener in ReceivedRequestTEA -Added some "No internet" toasts here and there. * Foreground notifications in place * Added notification sound
- Loading branch information
1 parent
101f34d
commit f2ebb80
Showing
18 changed files
with
4,694 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/src/main/java/garbagecollectors/com/snucabpool/FirebaseMessagingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package garbagecollectors.com.snucabpool; | ||
|
||
import android.app.PendingIntent; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.support.v4.app.NotificationCompat; | ||
import android.support.v4.app.NotificationManagerCompat; | ||
|
||
import com.google.firebase.messaging.RemoteMessage; | ||
|
||
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService | ||
{ | ||
|
||
@Override | ||
public void onMessageReceived(RemoteMessage remoteMessage) | ||
{ | ||
super.onMessageReceived(remoteMessage); | ||
|
||
String notificationTitle = remoteMessage.getNotification().getTitle(); | ||
String notificationBody = remoteMessage.getNotification().getBody(); | ||
|
||
String clickAction = remoteMessage.getNotification().getClickAction(); | ||
|
||
Uri sound = Uri.parse(remoteMessage.getNotification().getSound()); | ||
|
||
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) | ||
.setSmallIcon(R.mipmap.ic_launcher) | ||
.setContentTitle(notificationTitle) | ||
.setContentText(notificationBody) | ||
.setPriority(NotificationCompat.PRIORITY_DEFAULT) | ||
.setSound(sound); | ||
|
||
//clicking on the notification | ||
Intent resultIntent = new Intent(clickAction); | ||
|
||
PendingIntent resultPendingIntent = | ||
PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); | ||
|
||
mBuilder.setContentIntent(resultPendingIntent); | ||
|
||
//issuing | ||
int notificationId = (int) System.currentTimeMillis(); | ||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); | ||
|
||
// Builds notification and issues it | ||
notificationManager.notify(notificationId, mBuilder.build()); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.