Skip to content Skip to sidebar Skip to footer

Getting Parse Push Notification In List View

I am using parse push notification for my app , the notification comes fine but on clicking the notification I need to show them in a list view , I searched for tutorials but I cou

Solution 1:

At first add this to your manifest

-->
<uses-permissionandroid:name="android.permission.WAKE_LOCK" /><uses-permissionandroid:name="android.permission.VIBRATE" /><uses-permissionandroid:name="android.permission.RECEIVE_BOOT_COMPLETED" /><uses-permissionandroid:name="android.permission.GET_ACCOUNTS" /><uses-permissionandroid:name="com.google.android.c2dm.permission.RECEIVE" /><permissionandroid:name="YOURPACKAJE.permission.C2D_MESSAGE"android:protectionLevel="signature" /><uses-permissionandroid:name="YOURPACKAJE.permission.C2D_MESSAGE" />

add it to application tag

<serviceandroid:name="com.parse.PushService" /><receiverandroid:name="com.parse.ParseBroadcastReceiver" ><intent-filter><actionandroid:name="android.intent.action.BOOT_COMPLETED" /><actionandroid:name="android.intent.action.USER_PRESENT" /></intent-filter></receiver><receiverandroid:name="YOURPACKAJE.notifications.MyReceiver"android:exported="false" ><intent-filter><actionandroid:name="com.parse.push.intent.RECEIVE" /><actionandroid:name="com.parse.push.intent.DELETE" /><actionandroid:name="com.parse.push.intent.OPEN" /></intent-filter></receiver><receiverandroid:name="com.parse.GcmBroadcastReceiver"android:permission="com.google.android.c2dm.permission.SEND" ><intent-filter><actionandroid:name="com.google.android.c2dm.intent.RECEIVE" /><actionandroid:name="com.google.android.c2dm.intent.REGISTRATION"/><categoryandroid:name="YOURPACKAJE" /></intent-filter></receiver>

then create class in packaje YOURPACKAJE.notifications.MyReceiver

import java.util.List;
import java.util.Random;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log;
import android.widget.TextView;

import com.parse.ParseAnalytics;
import com.parse.ParsePushBroadcastReceiver;


publicclassMyReceiverextendsParsePushBroadcastReceiver {

    protectedvoidonPushReceive(Context mContext, Intent intent) {

        Log.e("ParsePush", "RECIVED");
        if (intent.hasExtra("com.parse.Data")){
            String jsonString=intent.getExtras().getString("com.parse.Data");

            Log.e("", "json " + jsonString);

                JSONObject json = newJSONObject(jsonString);

                String title= json.getString("title");
                String message= json.getString("message");
    // then call your method to create manually your custom notification with pending intent//in intent putExtra("title",title), putExtra("message",message)//and the after opening in Activity catch this intent
                 }
             }
        }

in wersite parse.com send notification like JSON

{"title":"your tittle is here","message":"your message"}

Solution 2:

dont use getIntent() , use intent in method:

@OverrideprotectedvoidonNewIntent(Intent intent) {
        String message = intent.getExtras().getString("alert");
        notifTv.setText(message);
    }

Post a Comment for "Getting Parse Push Notification In List View"