Skip to content

Instantly share code, notes, and snippets.

@pandeia
pandeia / NotificationHelpers.java
Created January 27, 2018 08:17
Method for deep-linking to an Apps Notification Settings
public static void openNotificationSettings()
{
Context context = Application.getAppContext();
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.putExtra("app_uid", context.getApplicationInfo().uid);
intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
intent.putExtra("app_package", context.getPackageName());
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1)
{
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
@pandeia
pandeia / MyFirebaseMessagingService.java
Created January 27, 2018 08:00
Example of an Implementation for onMessageReceived
@Override
public void onMessageReceived(RemoteMessage remoteMessage)
{
if (null != remoteMessage)
{
if (remoteMessage.getNotification() != null)
{
// The Message contains a notification payload.
// Note, that this can only happen, when app is in FOREGROUND
// Messages that contain a notification payload DO NOT TRIGGER onMessageReceived in background
@pandeia
pandeia / payload.json
Created January 27, 2018 07:06
An Example for an APNS Notification Payload
{
"aps" :
{
"alert" :
{
"title" : "Game Request",
"body" : "Bob wants to play poker",
"action-loc-key" : "PLAY"
},
"content-available" : 1,