Android

Hello, I implemented me own GcmListenerService with my own implementation of showing push. But, for tracking Openning Push in PushWoosh Dashboard, i have to call like this

Intent intent = new Intent();
intent.putExtras(data);
intent.setAction("com.google.android.c2dm.intent.RECEIVE");
intent.setComponent(new ComponentName(getPackageName(), component));
GcmReceiver.startWakefulService(getApplicationContext(), intent);

And if i do it, it shows double push notification in status bar. How can i track Openning Push in PushWoosh Dashboard and don't show it by pushWooshService from Sdk?

asked 11 Jul, 07:38
Justix's gravatar image

Justix
112

Hi there I had discussion with Vitaly from Push Woosh Team and he explained me how to handle my issue:

We can create our own Receiver to catch Push Clicks and send tracking to PushWoosh Dashboard by ourself

 public class NotificationReceiver extends BroadcastReceiver
    {
        public void onReceive(Context context, Intent intent)
        {
            if (intent == null)
                return;

            //Let Pushwoosh SDK to pre-handling push (Pushwoosh track stats, opens rich pages, etc.).
            //It will return Bundle with a push notification data
            Bundle pushBundle = PushManagerImpl.preHandlePush(context, intent);
            if(pushBundle == null)
                return;

            //get push bundle as JSON object
            JSONObject dataObject = PushManagerImpl.bundleToJSON(pushBundle);

            //Get default launcher intent for clarity
            Intent launchIntent  = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
            launchIntent.addCategory("android.intent.category.LAUNCHER");

            launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

            //Put push notifications payload in Intent
            launchIntent.putExtras(pushBundle);
            launchIntent.putExtra(PushManager.PUSH_RECEIVE_EVENT, dataObject.toString());

            //Start activity!
            context.startActivity(launchIntent);

            //Let Pushwoosh SDK post-handle push (track stats, etc.)
            PushManagerImpl.postHandlePush(context, intent);
        }
    }

<receiverandroid:name="your.app.package.notificationreceiver"/> <meta-data android:name="PW_NOTIFICATION_RECEIVER" android:value="${notificationReceiverPackage}.NotificationReceiver"/>

permanent link
answered 12 Jul, 14:00
Justix's gravatar image

Justix
112

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×427
×417
×6
×5

question asked: 11 Jul, 07:38

question was seen: 154 times

last updated: 12 Jul, 14:00