How to automatically open app when receive push notification? - android

I want to automatically open app when receive push notification.
I've tried but it still does not work as I expected.
This code below is work when the app is active or in MainActivity, but it's not work when the app in the background or just show notification on tray.
Did I miss something?
public class MyFirebaseMessagingService extends FirebaseMessagingService {
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if (remoteMessage.getNotification() != null) {
if (PreferencesUtil.getInstance(this).isLoggedIn()) {
sendNotification(remoteMessage.getData().get("order_id"));
}
}
}
public void sendNotification(String messageBody) {
NotificationManager notificationManager = null;
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder notificationBuilder;
notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle("Notification")
.setSmallIcon(R.mipmap.icon_notif)
.setContentText(messageBody)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setDefaults(Notification.DEFAULT_LIGHTS );
//add sound
try {
Uri sound = Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.siren);
Ringtone ringtone = RingtoneManager.getRingtone(this, sound);
ringtone.play();
notificationBuilder.setSound(sound);
} catch (Exception e) {
e.printStackTrace();
}
//vibrate
long[] v = {1000, 1000, 1000, 1000, 1000};
notificationBuilder.setVibrate(v);
notificationManager.notify(0, notificationBuilder.build());
Intent i = new Intent(this, NotificationActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
}

This is something need to handle from backend,
Here is a sample payload you are using right now,
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification":{
"title":"Portugal vs. Denmark",
"body":"great match!"
}
}
}
Which will only give you control to manipulate and do some action when your app will be in foreground otherwise just raise notification.
In details you can check here.
Now, To always get control over your notification, you need payload like following,
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data":{
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
}
}
}
The difference is you need to send data payload instead of notification poayload from backend.

int requestID = (int) System.currentTimeMillis();
Intent notificationIntent = new Intent(getApplicationContext(), NotificationActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, requestID,notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
And add PendingIntent like this
notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle("Notification")
.setSmallIcon(R.mipmap.icon_notif)
.setContentText(messageBody)
.setContentIntent(contentIntent);
.setPriority(NotificationCompat.PRIORITY_MAX)
.setDefaults(Notification.DEFAULT_LIGHTS );

Firstly, the concept of "application" in Android is slightly an extended one.
An application - technically a process - can have multiple activities, services, content providers and/or broadcast listeners. If at least one of them is running, the application is up and running (the process).
So, what you have to identify is how do you want to "start the application".
Ok... here's what you can try out:
Create an intent with action=MAIN and category=LAUNCHER
Get the PackageManager from the current context using context.getPackageManager
packageManager.queryIntentActivity(<intent>, 0) where intent has category=LAUNCHER, action=MAIN or packageManager.resolveActivity(<intent>, 0) to get the first activity with main/launcher
Get the ActivityInfo you're interested in
From the ActivityInfo, get the packageName and name
Finally, create another intent with with category=LAUNCHER, action=MAIN, componentName = new ComponentName(packageName, name) and setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
Finally, context.startActivity(newIntent)

I give complete example of this type of situation. Where i'll send a msg to a number (whether my app is completely killed or is in background or is in foreground ) according to received data payload
{
"registration_ids":["cMcyU3CaSlCkjPh8C0qo-n:APA91bFwOhNAwYp5vEEztv_yD_vo1fWt7TsiKZQ8ZvIWx8CUKZa8CNVLAalxmV0FK-zwYgZnwdAnnVaHjUHYpqC89raTLXxAfUWc2wZu94QWCnv14zW4b_DwDUMBpDo3ybP3qf5Y5KM2"],
"data": {
"number": "6299018534",
"msg": "Hii i am sidharth"
}
}
When you send this type data notification from your server then this will receive in onMessageReceived whether your app is in background or foreground.
So, Android code looks like this:
public class NotificationServices extends FirebaseMessagingService {
#Override
public void onMessageReceived(#NonNull RemoteMessage message) {
super.onMessageReceived(message);
if(message.getData().size()>0){
String number = null,msg = null;
if(message.getData().get("number") !=null){
number= message.getData().get("number");
}
if(message.getData().get("msg") !=null){
msg= message.getData().get("msg");
}
sendSms(number,msg);
}
}
#Override
public void onNewToken(#NonNull String token) {
super.onNewToken(token);
}
private void sendSms(String phone,String sms){
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phone,null,sms,null,null);
}
}
Happy coding :)

Related

How do I define a title for a data-payload firebase notification when the app is not running?

I am converting a GCM-based messaging app to firebase. Messages are being sent to the app using the data-payload format. If my app is running, either in the foreground or background, the code in OnMessageRecieved runs and sets the notification title. But if the app is not running when the notification is recieved it does not display a title. I have tried adding a title to the data payload:
{
"data": {
"title": "My Title",
"message": "Text of the message",
}
}
and also have tried defining it in the AndroidManifest.xml following the format of defining the icon:
<meta-data android:name="com.google.firebase.messaging.default_notification_title" android:value="My Title"/>
but neither of these methods have worked.
public override void OnMessageReceived(RemoteMessage message)
{
try
{
SendNotification(message.GetNotification()?.Body, message.Data);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
void SendNotification(string messageBody, IDictionary<string, string> data)
{
var intent = new Intent(this, typeof(MainActivity));
intent.AddFlags(ActivityFlags.ClearTop);
foreach (string key in data.Keys)
{
if (key == "message")
messageBody = data[key];
else
intent.PutExtra(key, data[key]);
}
var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
var notificationBuilder = new Notification.Builder(this)
.SetSmallIcon(Resource.Drawable.smallicon)
.SetContentTitle(AppInfo.DisplayName)
.SetContentText(messageBody)
.SetAutoCancel(true)
.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate)
.SetContentIntent(pendingIntent);
var notificationManager = NotificationManager.FromContext(this);
notificationManager.Notify(0, notificationBuilder.Build());
}
Turns out OnMessageRecieved IS being run, the issue was with the setting of the title itself:
.SetContentTitle(AppInfo.DisplayName)
AppInfo.DisplayName is set in the OnCreate method of MainActivity. I replaced the variable with:
.SetContentTitle(ApplicationInfo.LoadLabel(PackageManager))
and that displays the app name as the title in notifications that are received when the app is not running. Thanks BobSnyder for pointing me in the right direction!

How to send Notification from FirebaseMessagingService in Android

There are lot of questions already available on SO about this topic and I am not saying that I am doing something unique.
In my FirebaseMessagingService, I am sending Broadcast to show Notification when data message is received.
Here is my code:
public class MessagingService extends FirebaseMessagingService {
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if (remoteMessage.getData().size() > 0) {
Log.e(TAG, "Message data payload: " + remoteMessage.getData());
String topic = remoteMessage.getData().get(AppConstants.Notification.TOPIC);
if(topic != null) {
switch (topic) {
case FirebaseUtils.TopicMessaging.TOPIC_TASK:
String assignedTo = remoteMessage.getData().get(AppConstants.Notification.ASSIGNED_TO);
//String empId = remoteMessage.getData().get(AppConstants.Notification.EMP_ID);
//String assignedBy = remoteMessage.getData().get(AppConstants.Notification.ASSIGNED_BY);
String title = remoteMessage.getData().get(AppConstants.Notification.TITLE);
String body = remoteMessage.getData().get(AppConstants.Notification.BODY);
if (assignedTo.equals(FotApplication.Employee.Id)) {
//sendNotification(body, title);
Intent intent = new Intent("MY_INTENT_FILTER");
intent.putExtra(AppConstants.Notification.ASSIGNED_TO, assignedTo);
intent.putExtra(AppConstants.Notification.TITLE, title);
intent.putExtra(AppConstants.Notification.BODY, body);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
sendBroadcast(intent);
}
break;
}
}
}
In AndroidManifest.xml
<receiver
android:name=".NotificationReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="MY_INTENT_FILTER"/>
</intent-filter>
</receiver>
NotificationReceiver
public class NotificationReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if(intent != null){
String body = null, title = null;
if(intent.hasExtra(AppConstants.Notification.BODY)){
body = intent.getStringExtra(AppConstants.Notification.BODY);
}
if(intent.hasExtra(AppConstants.Notification.TITLE)){
title = intent.getStringExtra(AppConstants.Notification.TITLE);
}
if(body != null && title != null) {
sendNotification(context, body, title);
}
}
}
private void sendNotification(Context context, String message, String title) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
NotificationChannel channel;
if (Build.VERSION.SDK_INT >= 26) {
channel = new NotificationChannel("default",
"Task",
NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("Task Channel");
notificationManager.createNotificationChannel(channel);
}
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, "default")
.setSmallIcon(R.drawable.ic_notification_new)
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
.setVibrate(new long[]{0, 500})
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
notificationManager.notify(0, notificationBuilder.build());
}
}
}
NOTE I have tried everything from sending notification from FCM Json to receive it in FirebaseMessagingService but when App is closed (closed mean neither in Foreground nor Background) then notifications did not show up. Though data message is delivered to System tray.
The last thing I am trying to do is sending Broadcast but that's not working as well. Might be my bad. I have gone through several links and implemented every solution but that Notification thing haven't shown up anywhere. Don't know how big giants (WhatsApp, Facebook, Microsoft, Google) are doing it.
How to Send BroadCast from one app to another app
Why is my broadcast receiver not working
Broadcast and Broadcast receiver
FCM Messaging Concept
Firebase cloud messaging notification not received by device
enter link description here
Is there any workaround then let me know!

Get Firebase notification when app is in background (with only data-payload using REST client)

I want to receive notification when the app is in background with the data-payload only. I don't want to send any notification parameters like "notification" : {"sound": "default"}
Here is my code to receive the message and build notification.
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String URL_KEY = "url";
private static final String TITLE_KEY = "title";
private static final String BODY_KEY = "body";
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (remoteMessage.getNotification() != null) { //Here I made the dumb mistake
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
// Notification Data initialization
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
// String notificationTitle = remoteMessage.getNotification().getTitle();
String notificationTitle = remoteMessage.getData().get(TITLE_KEY);
// String notificationBody = remoteMessage.getNotification().getBody();
String notificationBody = remoteMessage.getData().get(BODY_KEY);
String receivedUrl = remoteMessage.getData().get(URL_KEY);
// BuildNotificaiton
Intent internetIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(receivedUrl))
.setComponent(new ComponentName("com.example.suvajit.webview", "com.example.suvajit.webview.MainActivity"))
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
Random generator = new Random();
PendingIntent btn1Intent = PendingIntent.getActivity(this, generator.nextInt(), internetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle(notificationTitle)
.setContentText(notificationBody)
.setSmallIcon(R.mipmap.ic_launcher)
.setSound(defaultSoundUri)
.setAutoCancel(true)
.addAction(R.mipmap.ic_launcher, "Previous", btn1Intent) // #0
.addAction(R.mipmap.ic_launcher, "Pause", null) // #1
.addAction(R.mipmap.ic_launcher, "Next", null) // #2
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
}
}
This is my manifest:
<service android:name="com.example.suvajit.webview.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="com.example.suvajit.webview.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
And I'm sending notification using ARC
But when I'm sending only data payload notification is not received even if the app is in foreground.
{ "data": {
"url": "https://www.google.com",
"body" : "This is your message",
"title": "v-comply",
}
"to" : "dOa...hXIWnms"
}
When I'm sending sound or any thing else as notification parameter and the app is in foreground the notification is working as it should but when its in background its showing only my project name , the data part is not received I guess.
{ "data": {
"url": "https://www.google.com",
"body" : "This is your message",
"title": "v-comply",
},
"notification" : {
"sound": "default"
},
"to" : "dOa...hXIWnms"
}
Below there are two screenshots of notification when app in background and in foreground respectively.
How can I make it work to get notifications when my app is in background with only data-payload? Or am I doing something wrong? Someone please give a solution or guide me.
This was a very dumb and silly mistake which I have made. I was only sending data payload , but I was checking remoteMessage.getNotification() != null which means it doesen't run my code if there is nothing in my notification data. The condition should be like this
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (remoteMessage.getData().size() > 0) {
//Do stuffs to show notification with data payload only
}
}
After all my notification is working as expected.
This is for other users.
If someone wants to have both notification and data payload check separately they can include both conditions like this.
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (remoteMessage.getData().size() > 0) {
//Do stuffs with data payload only
}
if (remoteMessage.getNotification() != null) {
//Do stuffs with notificaiton data
}
}

Parse.com - Android custom push notification sound

I know that push notification sound, in Android, can be customised (on iOS already working).
However, I don't see any reference in the docs, only per iOS custom sound.
I saw in Parse.com forum that such a feature was requested about a year ago and answered that it was "on the table".
Any updates regarding that? If not "officially" supported, any known workaround to get it working?
I figured out a solution. This is not available through Parse's API yet but they do have documentation which explains how to extend their ParsePushBroadcastReceiver.
So create a class which extends the ParsePushBroadcastReceiver, and onReceive call a method generateNotification and write the custom code to create a custom notification of your own there. This way, you can include a sound. First of all, you would need to add the new sound file (ex mp3) to a raw directory in the resources / res folder.
By the way, don't forget to change the ParsePushBroadcastReceiver receiver from the manifest to reflect your new file. Example:
<receiver android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
to
<receiver android:name="com.*my_package_name*.MyBroadcastReceiver"
android:exported="false">
Here's my code. It works and it's reusable.
public class MyBroadcastReceiver extends ParsePushBroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
try {
String jsonData = intent.getExtras().getString("com.parse.Data");
JSONObject json = new JSONObject(jsonData);
String title = null;
if(json.has("title")) {
title = json.getString("title");
}
String message = null;
if(json.has("alert")) {
message = json.getString("alert");
}
if(message != null) {
generateNotification(context, title, message);
}
} catch(Exception e) {
Log.e("NOTIF ERROR", e.toString());
}
}
private void generateNotification(Context context, String title, String message) {
Intent intent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationManager mNotifM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if(title == null) {
title = context.getResources().getString(R.string.app_name);
}
final NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon)
.setContentTitle(title)
.setContentText(message)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(message))
.addAction(0, "View", contentIntent)
.setAutoCancel(true)
.setDefaults(new NotificationCompat().DEFAULT_VIBRATE)
.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.whistle));
mBuilder.setContentIntent(contentIntent);
mNotifM.notify(NOTIFICATION_ID, mBuilder.build());
}
}
At the end of this tutorial is explained how to play custom sounds on the push notifications.
It is done using this line:
notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
Another option to provide sound without having to generate your own notification is to just add a sound to the notification that Parse already creates for you like this:
public class MyParsePushBroadcastReceiver extends ParsePushBroadcastReceiver {
#Override
protected Notification getNotification(Context context, Intent intent) {
Notification n = super.getNotification(context, intent);
n.sound = Uri.parse("android.resource://" + context.getPackageName() + "/some_sound.mp3");
return n;
}
}

how to implement the push notification in android

I am doing lots of Research on push notification but i don't understand how to implement in android 1.6. I want to ask what is the requirements for this? which type of information we get from the server end either in tags form or just information? what will be the input or output regarding this.Which input i give to the server and which output comes from the server.
is there any device id to be require for this? Please suggest me Thanks .
This is the link to documentation given by the Google. They named the concept of PushNotification as C2DM (Cloud To Device Messaging)
You can get a clear description by visiting the given link. I'll give you some short answere for your questions.
You can't implement this in Android 1.6. You need 2.2 or higher
version
As PushNotification, we get only alerts, not the full details message.
As input for the third party server, should have the device registration ID with the C2DM.
Yes, there should be a device id to identify the device to activate the service. You can get it at the initial phase where your Android app try to connect with the C2DM
In Firebase we can push notification with multiple pieces of information to the specific or multiple devices for that we need to implement some code from the android side, first, we need to set up the firebase configuration in your app, I will cover how to redirect push notification to specific or default a screen in the mobile application.
Two ways to open the application screen
By default when you only need to open the application(Like splash screen).
Redirect to the specific screen in the application.
By default when you only need to open the application(Like splash screen)
Create a class Named "FirebaseMessagingService" and extends "FirebaseMessagingService"
Code to implement
public class FirebaseMessagingService extends FirebaseMessagingService
{
#Override
public void onNewToken(String token)
{
sendRegistrationToServer(token);
}
public void onMessageReceived(RemoteMessage remoteMessage)
{
String title = remoteMessage.getNotification().getTitle();
String body = remoteMessage.getNotification().getBody();
Uri imageUrl = remoteMessage.getNotification().getImageUrl();
String actionItem = remoteMessage.getNotification().getClickAction();
if (imageUrl == null)
{
MyNotificationManager.getmInstance(getApplicationContext()).displayNotificationAction(title, body,actionItem);
}
else
{
MyNotificationManager.getmInstance(getApplicationContext()).displayImageNotification(title, body, imageUrl);
}
}
private void sendRegistrationToServer(String token)
{
// TODO: Implement this method to send a token to your app server.
}
}
Create Notification Manager class to manage the display method with different parameters
public class MyNotificationManager
{
private Context mCtx;
private static MyNotificationManager mInstance;
private MyNotificationManager(Context context)
{
createNotificationChannel();
mCtx = context;
}
public static synchronized MyNotificationManager getmInstance(Context context)
{
if (mInstance == null)
{
mInstance = new MyNotificationManager(context);
}
return mInstance;
}
public void createNotificationChannel()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel("1", "Testing the Notification", importance);
channel.setDescription("We are testing the notification");
}
}
public void displayNotification(String title, String body)
{
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mCtx, Constant.CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_notification)
.setColor(ContextCompat.getColor(mCtx, R.color.colorPrimary))
.setContentTitle(title)
.setContentText(body);
Intent intent = new Intent(mCtx, SplashActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(mCtx, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pendingIntent);
NotificationManager mNotificationManager = (NotificationManager) mCtx.getSystemService(Context.NOTIFICATION_SERVICE);
if (mNotificationManager != null)
{
mNotificationManager.notify(1, mBuilder.build());
}
}
public void displayImageNotification(String title, String body, Uri imageUrl)
{
NotificationCompat.Builder notification = null;
NotificationManager mNotificationManager = null;
try
{
notification = new NotificationCompat.Builder(mCtx, Constant.CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_notification)
.setContentTitle(title)
.setAutoCancel(true)
.setColor(ContextCompat.getColor(mCtx, R.color.colorPrimary))
.setLargeIcon(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Picasso.with(mCtx).load(imageUrl).get() : Picasso.with(mCtx).load(R.mipmap.ic_notification).get())
.setContentText(body)
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(Picasso.with(mCtx).load(imageUrl).get())
.bigLargeIcon(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Picasso.with(mCtx).load(imageUrl).get() : Picasso.with(mCtx).load(R.mipmap.ic_notification).get()));
Intent intent = new Intent(mCtx, SplashActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(mCtx, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setContentIntent(pendingIntent);
mNotificationManager = (NotificationManager) mCtx.getSystemService(Context.NOTIFICATION_SERVICE);
if (mNotificationManager != null)
{
notification.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(1, notification.build());
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
Now just trigger the notification through Firebase console or send through API like:-
{
"to": "device_token",
"priority": "high",
"notification": {
"body": "Happy Coding",
"title": "All things are difficult before they are easy.",
"image":""
},
"data": {
"image":""
}
}
2.Redirect to the specific screen in the application.
Open the AndroidManifest.xml and in activity tag you need to define ...
....
<activity
android:name=".activity.SpedificActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="SpedificActivityNotification" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
....
now call the API
{
"to": "device_token",
"priority": "high",
"notification": {
"body": "Happy Coding",
"title": "All things are difficult before they are easy.",
"click_action": "SpedificActivityNotification",
"image":""
},
"data": {
"image":""
}
}

Categories

Resources