phonegap local notification - android

i have implemented a local notification in my android app using phonegap
localnotification plugin.
notification get trigger properly but while clicking on notification
app does not open.
what i want to relaunch a app on clicking of status notification.
Thanks and regards

In AlarmReciever class, in onRecieve event, change the line 79,
final PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
to
final PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context,mainActivity.class), 0);
It starts, new activity

Related

What methods are called when opening app from push notification

I'm trying to figure out what methods are called when my app is opened by tapping on a push-notification banner. The app appears to re-launch?
you can use pending Intent, like this:
val intent = Intent(this#MyFirebaseMessagingService, NextActivity::class.java)
val pendingIntent = PendingIntent.getActivity(this, 101, intent,
PendingIntent.FLAG_UPDATE_CURRENT)
and set pendingIntent to your notification.Builder.

Click on notification and then go to next detail page where there is also the detail of that are present

I am the student of computer science last semester student.
I have problem:
I set my Android Application that receive notification from online database of job finder web application.When new entry occur then notification comes here on Android App.
So now i want if i click that notification then there will be a page open in which the detail of that job will present.
so please guid me i have only few days to submit my final year project.
I will be very thankfull.
Have a look at the Android Developers Guide. There they describe to set up a PendingIntent to react to the click on the notification.
PendingIntent resultPendingIntent;
...
mBuilder.setContentIntent(resultPendingIntent); // Code comes directly from this Developer Guide
You have to use Pending Intent to open page when click on Notification.
// prepare intent which is triggered if the
// notification is selected
Intent intent = new Intent(this, YourActivityToBeOpen.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
You can find more details here.
To create Notification :
NotificationManager mgr = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
Notification note = new Notification(R.drawable.stat_notify_chat,
"Android Example Status message!",
System.currentTimeMillis());
// This pending intent will open after notification click
Intent i = new Intent(this, NotifyMessage.class);
PendingIntent i = PendingIntent.getActivity(this, 0, i, 0);
note.setLatestEventInfo(this, "Android Example Notification Title",
"This is the android example notification message", i);
// After uncomment this line you will see number of notification arrived
// note.number=2;
mgr.notify(NOTIFY_ME_ID, note);
Intent i = new Intent(this, NotifyMessage.class);
PendingIntent i = PendingIntent.getActivity(this, 0, i, 0);
Its manage your navigation after click on notification. If you want no navigation then use :
Intent i = new Intent();
PendingIntent i = PendingIntent.getActivity(this, 0, i, 0);
I hope it will help.

Save to DB after clear the push notification android

I am working with push notification and I have one problem.
When I click in the received notification my code launch a new intent with an activity.
I use:
Intent i = new Intent(getApplicationContext(), DemoActivity.class);
i.putExtra("msg",msg);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
i, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(contentIntent);
ITS OK FOR ME
But if I want only save this notification in SQLite how can I pass the message?
I know that with:
Intent bd = new Intent(getApplicationContext(), AbaseDatos.class);
bd.putExtra("msg",msg);
PendingIntent contentIntentbd = PendingIntent.getActivity(this, 0,
bd, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setDeleteIntent(contentIntentbd);
Call a new activity when clear the notification, but the new activity open the layout.
I dont want any new activity be launched. Its possible launch a javaclass with an Intent?
Any idea?
You can launch a service with an intent.
http://developer.android.com/reference/android/app/PendingIntent.html#getService(android.content.Context%2C%20int%2C%20android.content.Intent%2C%20int)

Android - Track Notification onclicked

I want to start a activity when users clicked on notification but there are no onclicked event for notification (?), so how can we know when the notification is clicked?
Thanks!
http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Look into PendingIntent setup there.
The PendingIntent will get called when you click the notification.
Intent notificationIntent = new Intent(this, MyClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notificationIntent will be called when notification is clicked.

Android notification click

I am running a service which is popping notification on getting a new task. If I close my app it's running in the background and pop up a notification. What I would like to do is, when I click on that notification, open the app. Can I do that ? How ?
You can do this by adding an intent to your notification:
Intent notificationIntent = new Intent(context, YourAppActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, "headline", "body msg", contentIntent);
notifcationMgr.notify(id, notification);
Just replace YourAppActivity with the activity you want to launch.

Categories

Resources