using System; using Android.Content; using Android.OS; using CN.Jpush.Android.Api; using CN.Jpush.Android.Service; namespace com.hdl.on { // // // // // // // // // // // // // // /* *创建一个广播 * 自定义接收器 * 如果不定义这个 Receiver,则: * 1) 默认用户会打开主界面 * 2) 接收不到自定义消息 */ //[BroadcastReceiver] //[IntentFilter(new string []{"cn.jpush.android.intent.REGISTRATION", "cn.jpush.android.intent.MESSAGE_RECEIVED","cn.jpush.android.intent.NOTIFICATION_RECEIVED","cn.jpush.android.intent.NOTIFICATION_OPENED","cn.jpush.android.intent.CONNECTION"})] public class MyReceiver : BroadcastReceiver { static string ACTION = "android.intent.action.BOOT_COMPLETED"; public override void OnReceive (Context context, Intent intent) { Bundle bundle = intent.Extras; if (intent.Action == ACTION) { //开机自动服务自动启动,PushService是要启动的服务 Intent service = new Intent (context, typeof (PushService)); context.StartService (service); } //接收Registration Id if (JPushInterface.ActionRegistrationId == intent.Action) { string regId = bundle.GetString (JPushInterface.ExtraRegistrationId); } //用户点击打开了通知 else if (JPushInterface.ActionNotificationOpened == intent.Action) { Application.IsShowTip = false; Intent i = new Intent (context, typeof (Shared.BaseActivity));//Intent intent=new Intent( 起始组件对象 , 目标 Service.class); i.PutExtras (bundle); i.SetFlags (ActivityFlags.NewTask); context.StartActivity (i); } else { } } } }