| | |
| | | using System; |
| | | using Android.Content; |
| | | using Android.OS; |
| | | using CN.Jpush.Android.Api; |
| | | using CN.Jpush.Android.Service; |
| | | //using System; |
| | | //using Android.Content; |
| | | //using Android.OS; |
| | | //using CN.Jpush.Android.Api; |
| | | //using CN.Jpush.Android.Service; |
| | | |
| | | namespace com.hdl.on |
| | | { |
| | | //<receiver android:name="com.hdl.on.MyReceiver" android:exported="false" android:enabled="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> |
| | | // <intent-filter> |
| | | // <action android:name="cn.jpush.android.intent.REGISTRATION" /> |
| | | // <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> |
| | | // <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> |
| | | // <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> |
| | | // <action android:name="cn.jpush.android.intent.CONNECTION" /> |
| | | // <category android:name="com.hdl.on" /> |
| | | // <action android:name="android.intent.action.BOOT_COMPLETED"></action> |
| | | // <category android:name="android.intent.category.LAUNCHER" /> |
| | | // <action android:name="android.intent.action.USER_PRESENT" /> |
| | | // <action android:name="android.media.RINGER_MODE_CHANGED" /> |
| | | // </intent-filter> |
| | | //</receiver> |
| | | /* |
| | | *创建一个广播 |
| | | * 自定义接收器 |
| | | * 如果不定义这个 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"; |
| | | //namespace com.hdl.on |
| | | //{ |
| | | // //<receiver android:name="com.hdl.on.MyReceiver" android:exported="false" android:enabled="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> |
| | | // // <intent-filter> |
| | | // // <action android:name="cn.jpush.android.intent.REGISTRATION" /> |
| | | // // <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> |
| | | // // <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> |
| | | // // <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> |
| | | // // <action android:name="cn.jpush.android.intent.CONNECTION" /> |
| | | // // <category android:name="com.hdl.on" /> |
| | | // // <action android:name="android.intent.action.BOOT_COMPLETED"></action> |
| | | // // <category android:name="android.intent.category.LAUNCHER" /> |
| | | // // <action android:name="android.intent.action.USER_PRESENT" /> |
| | | // // <action android:name="android.media.RINGER_MODE_CHANGED" /> |
| | | // // </intent-filter> |
| | | // //</receiver> |
| | | // /* |
| | | // *创建一个广播 |
| | | // * 自定义接收器 |
| | | // * 如果不定义这个 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; |
| | | // 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); |
| | | } |
| | | // 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 { |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // //接收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 { |
| | | // } |
| | | // } |
| | | // } |
| | | //} |