1

I am using Parse API in order to handle push notifications. In our Android application, I want to accomplish two things:

1) If we have received a Push Notification with the application is closed and the user clicks on the notification, I want to be able to understand that the application is being opened via a push notification.

2)If we receive a push notification while the application is open, I want to handle this and do some extra work.

In both cases, I want to be aware that the application has received a push notification in order to execute some special operations.

As far as I understand from Parse API documentations, it offers two methods of handling pushes: Responding with an Activity and Responding with an Intent. I am currently calling

PushService.setDefaultPushCallback(context, MainActivity.class);

in my Application class with needed changes in the AndroidManifest.xml file and already receive push notifications, this corresponds to Responding with an Activity method. But I don't know how to be aware of Push Notifications explicity with this method.

Thanks in advance.

Ufuk Can Bicici
  • 3,589
  • 4
  • 28
  • 57
  • When you receive the Push Notification, you have the choice of calling the required activity(In AndroidManifest.xml). Use that. – Akshat Singhal Feb 07 '14 at 10:03
  • How is this done? And by calling the activity, do we mean a specific method of it? – Ufuk Can Bicici Feb 07 '14 at 10:14
  • A `Receiver` has to be created which would *receive* the push messages. In that receiver, you can do anything you want. – Akshat Singhal Feb 07 '14 at 10:19
  • 1
    This is a class of type BroadcastReceiver, am I right? So, if I receive a push notification while the app is closed, only this class is called by the system, without the rest of the application is being instantiated? – Ufuk Can Bicici Feb 07 '14 at 10:24
  • @UfukCanBiçici Did you find a solution? I'm facing the same problem. – Anirudh Jan 20 '15 at 09:42

1 Answers1

2

When a push is received ,Check

1:Whether our application is in foreground or background.

If it is foreground, that means app is visible and do your stuff(show alerts or anything you want).

If app is in background,that means it is not visible and if you want to do any thing based on this.

i hope this helps..

KP_
  • 1,854
  • 25
  • 43