public override void OnReceive(Context context, Intent intent)
        {
            base.OnReceive(context, intent);
            if (intent.Action == JPushInterface.ActionNotificationOpened)
            {
                //When user tap the notification on notification center
                Bundle bundle   = intent.Extras;
                string jsonData = bundle.GetString(JPushInterface.ExtraExtra);
            }

            if (intent.Action == JPushInterface.ActionMessageReceived)
            {
                //When user tap the notification on notification center
                Bundle bundle   = intent.Extras;
                string jsonData = bundle.GetString(JPushInterface.ExtraExtra);
            }

            if (intent.Action == JPushInterface.ActionRegistrationId)
            {
                //Only call when first launch, get the registrationID
                string regID = JPushInterface.GetRegistrationID(context);
            }

            if (intent.Action == JPushInterface.ActionConnectionChange)
            {
                Bundle bundle   = intent.Extras;
                string jsonData = bundle.GetString(JPushInterface.ExtraExtra);
                string s        = JPushInterface.GetRegistrationID(context);
            }
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            JPushInterface.SetDebugMode(true);
            JPushInterface.Init(this);
            _common = new CommonFun_Droid();
            CopyLocalDB();
            //ToolbarResource = Resource.Layout.toolbar_layout;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
            {
                Android.Webkit.WebView.SetWebContentsDebuggingEnabled(true);
            }

            if (!Resolver.IsSet)
            {
                this.SetIoc();
            }
            //else
            //{
            //    var app = Resolver.Resolve<IXFormsApp>() as IXFormsApp<XFormsApplicationDroid>;
            //    if (app != null) app.AppContext = this;
            //}

            global::Xamarin.Forms.Forms.Init(this, bundle);

            commonhelper = Resolver.Resolve <CommonHelper>();
            if (commonhelper.IsNetWorkConnected())
            {
                //PgySdk
                PgyCrashManager.Register(this);
            }
            UserDialogs.Init(this);
            CachedImageRenderer.Init();
            SecureStorageImplementation.StoragePassword = "******";
            RegistUpdate();

            Xamarin.Forms.Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                {
                    e.NativeView.ContentDescription = e.View.StyleId;
                }
            };
            LoadApplication(new App());
            BackPressed += MainActivity_BackPressed;

            string regID = JPushInterface.GetRegistrationID(ApplicationContext);

            App.ScreenWidth  = (int)(Resources.DisplayMetrics.WidthPixels / Resources.DisplayMetrics.Density);
            App.ScreenHeight = (int)(Resources.DisplayMetrics.HeightPixels / Resources.DisplayMetrics.Density);
        }
 public override void OnReceive(Context context, Intent intent)
 {
     base.OnReceive(context, intent);
     if (intent.Action == JPushInterface.ActionNotificationReceived)
     {
         //When user tap the notification on notification center
         Bundle bundle           = intent.Extras;
         string notificationData = bundle.GetString(JPushInterface.ExtraAlert);
         CrossLocalNotifications.Current.Show("JPush", notificationData, 101);
     }
     if (intent.Action == JPushInterface.ActionRegistrationId)
     {
         //Only call when first launch, get the registrationID
         string regID = JPushInterface.GetRegistrationID(context);
         System.Console.WriteLine("Device ID:" + regID);
     }
 }
        public void OnClick(object sender, System.EventArgs e)
        {
            View v = sender as View;

            switch (v.Id)
            {
            case JPush.Resource.Id.init:
                init();
                break;

            case JPush.Resource.Id.setting:
                //Intent intent = new Intent(MainActivity.this, typeof(PushSetActivity));
                //startActivity(intent);
                break;

            case JPush.Resource.Id.stopPush:
                JPushInterface.StopPush(ApplicationContext);
                break;

            case JPush.Resource.Id.resumePush:
                JPushInterface.ResumePush(ApplicationContext);
                break;

            case JPush.Resource.Id.getRegistrationId:
                string rid = JPushInterface.GetRegistrationID(ApplicationContext);
                if (rid.Length > 0)
                {
                    mRegId.Text = "RegId:" + rid;
                }
                else
                {
                    Toast.MakeText(this, "Get registration fail, JPush init failed!", ToastLength.Short).Show();
                }
                break;
            }
        }
Exemple #5
0
 public string GetRegistrationId()
 {
     return(JPushInterface.GetRegistrationID(Android.App.Application.Context));
 }