PushBots:如何在布局中显示通知?

时间:2014-07-14 09:23:36

标签: android google-cloud-messaging pushbots

我是堆叠溢出的新手。

我正在开发一个Android应用程序,它使用PushBots进行推送通知。我已准备好在我的应用程序中启用PushBots。我甚至可以发送推送通知。但我想存储通知文本并在应用程序内显示它们而不仅仅是通知栏。请帮我解决这个问题。如果我的语言不正确,请原谅我。

谢谢。

接收者类:

import java.util.HashMap;
import com.pushbots.push.Pushbots;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class customPushReceiver extends BroadcastReceiver
{
    private static final String TAG = "customPushReceiver";
    @Override
    public void onReceive(Context context, Intent intent)
    {
        String action = intent.getAction();
        Log.d(TAG, "action=" + action);
        // Handle Push Message when opened
        if (action.equals(Pushbots.MSG_OPENED)) {
            HashMap<?, ?> PushdataOpen = (HashMap<?, ?>)  intent.getExtras().get(Pushbots.MSG_OPEN);                intent.getExtras().get(Pushbots.MSG_OPEN);
        Log.w(TAG, "User clicked notification with Message: " + PushdataOpen.get("message"));
        // Start activity if not active
        // set the value of local variable "active" in onStart()/onStop() in MainActivity
        // to check for MainActivity status
        if(!MainActivity.isActive()){
            Intent launch = new Intent(Intent.ACTION_MAIN);
            launch.setClass(Pushbots.getInstance().appContext, MainActivity.class);
            launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            Pushbots.getInstance().appContext.startActivity(launch);
        }
        // Handle Push Message when received
        }else if(action.equals(Pushbots.MSG_RECEIVE)){
            HashMap<?, ?> Pushdata = (HashMap<?, ?>)  intent.getExtras().get(Pushbots.MSG_RECEIVE);
            Log.w(TAG, "User Received notification with Message: " + Pushdata.get("message"));
        }
    }
}

Pushbots Initialize:

Pushbots.getInstance().regID();

以下是Log中的一些最新行:

07-14 23:42:42.752:V / GCMBroadcastReceiver(2491):onReceive:com.google.android.c2dm.intent.RECEIVE

07-14 23:42:42.752:V / GCMBroadcastReceiver(2491):GCM IntentService类:com.pushbots.push.GCMIntentService

07-14 23:42:42.752:V / PBGCMBaseIntentService(2491):获取唤醒锁

07-14 23:42:42.760:I / PBGCMIntentService(2491):收到通知。

07-14 23:42:42.760:D / PBGenerateNotification(2491):当用户点击通知时,通知将从状态栏中取消。

07-14 23:42:42.764:D / PBRequestTask(2491):PUT请求:https://api.pushbots.com/stats

07-14 23:42:42.780:V / PBGCMBaseIntentService(2491):释放唤醒锁

07-14 23:42:49.888:D / PB(2491):PushBots请求成功!

07-14 23:43:51.532:D / PBMsgReceiver(2491):没有设置意图接收器,没有发送com.pushbots.MSG_OPENED

07-14 23:43:51.532:D / PBRequestTask(2491):PUT请求:https://api.pushbots.com/stats

07-14 23:43:51.812:D / PB(2491):PushBots请求成功!

0 个答案:

没有答案