如何实施Urban AirShip的通知或通知OFF?

时间:2011-01-21 18:42:13

标签: android

我正在开发一个Android应用程序,在我的应用程序中使用Urban Airship for Push notification.It工作正常,我想如果我点击UI中的“Notification On”,我会收到通知到我的设备,当我点击在我的用户界面中“通知关闭”,我不会收到通知我的设备。如何在Urban Airship中实现代码?怎么可能?

由于

2 个答案:

答案 0 :(得分:1)

启用它

PushManager.enablePush();

并禁用它

PushManager.disablePush();

答案 1 :(得分:0)

在您的按钮中点击此代码

final Intent intent = new Intent(Intent.ACTION_MAIN, null);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        final ComponentName cn = new ComponentName(
                "com.urbanairship.airmail",
                "com.urbanairship.airmail.MainListActivity");
        intent.setComponent(cn);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);

在你的清单文件中跟着这个把它放在你的android:name =" .QuadDealsPushReceiver"

创建一个QuadDealsPushReceiver.class并输入此代码..

包com.fsp.quaddeals;

import com.urbanairship.push.APIDReceiver; import com.urbanairship.push.AirMail; import com.urbanairship.push.PushReceiver;

import android.app.Application; import android.content.Intent; import android.util.Log;

公共类QuadDealsPushReceiver扩展Application {     public void onCreate(){         AirMail am = AirMail.getInstance();         am.acceptPush(this,new PushReceiver(){             @覆盖             public void onReceive(String message,String payload){                 Log.d(" push","得到消息'" +消息+"'&有效负载'" +有效负载+"'");             }

        @Override
        public void onClick(String message, String payload){
            Log.d("push", "User clicked the notification, got message and payload: "
                    + message + ", " + payload);
            /* In this example, we fire up our MainActivity class when the
             * user clicks the Status Bar Notification. Note that we *must*
             * use the flag Intent.FLAG_ACTIVITY_NEW_TASK to start a new
             * activity because this callback is fired from within a
             * BroadcastReceiver.
             **/
            Intent intent = new Intent("android.intent.action.MAIN");
            intent.setClass(QuadDealsPushReceiver.this, SplashMain.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            QuadDealsPushReceiver.this.startActivity(intent);
        }
    });

    am.setAPIDReceiver(this, new APIDReceiver() {
        @Override
        public void onReceive(String apid, boolean valid){
            if(valid){
                Log.d("push", "Got apid: " + apid);
            } else {
                Log.d("push", "Application registration invalid!"+ apid);
            }
        }

        @Override
        public void onAirMailInstallRefusal() {
            QuadMain.register = false;
            Log.d("push", "AirMail Install Refused!");
        }
    });
}

}

有关进一步说明,请使用此链接

Help for Push notification