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);
            }
        }
        private void OpenNotification(Context context, Bundle bundle)
        {
            //清除所有通知
            JPushInterface.ClearAllNotifications(context);
            //判断app进程是否存活
            if (EldYoungUtil.IsApplive(context, "com.lelaozu.communitycenter"))
            {
                //如果存活的话,就直接启动报警DetailActivity,但要考虑一种情况,就是app的进程虽然仍然在
                //但Task栈已经空了,比如用户点击Back键退出应用,但进程还没有被系统回收,如果直接启动
                //DetailActivity,再按Back键就不会返回任何界面了。所以在启动DetailActivity前,要先启动splash界面。
                Log.Info("NotificationReceiver", "the app process is alive");


                Intent mainIntent = new Intent(context, typeof(MainActivity));
                mainIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop);
                Intent alarmDetailInfoIntent = new Intent(context, typeof(AlarmDetailInfoActivity));
                bundle.PutString("alarmOrigin", "Jpush");
                alarmDetailInfoIntent.PutExtras(bundle);
                Intent[] intents = new Intent[] { mainIntent, alarmDetailInfoIntent };
                context.StartActivities(intents);
            }
            else
            {
                //如果app进程已经被杀死,先重新启动app,将alarmDetailActivity的启动参数传入Intent中,参数经过
                //SplashActivity传入MainActivity,此时app的初始化已经完成,在MainActivity中就可以根据传入,参数跳转到DetailActivity中去了
                Log.Info("NotificationReceiver", "the app process is dead");
                Intent launchIntent = context.PackageManager.GetLaunchIntentForPackage("com.lelaozu.communitycenter");
                launchIntent.SetFlags(
                    ActivityFlags.NewTask | ActivityFlags.ResetTaskIfNeeded);
                bundle.PutString("alarmOrigin", "Jpush");
                launchIntent.PutExtras(bundle);
                context.StartActivity(launchIntent);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 设置允许接收通知时间
        /// </summary>
        private void setPushTime()
        {
            int startime = startTime.CurrentHour;
            int endtime  = endTime.CurrentHour;

            if (startime > endtime)
            {
                Toast.makeText(SettingActivity.this, "开始时间不能大于结束时间", Toast.LENGTH_SHORT).show();
                return;
            }
            StringBuilder daysSB = new StringBuilder();
            ISet <int>    days   = new HashSet <int>();

            if (mSunday.Checked)
            {
                days.Add(0);
                daysSB.Append("0,");
            }
            if (mMonday.Checked)
            {
                days.Add(1);
                daysSB.Append("1,");
            }
            if (mTuesday.Checked)
            {
                days.Add(2);
                daysSB.Append("2,");
            }
            if (mWednesday.Checked)
            {
                days.Add(3);
                daysSB.Append("3,");
            }
            if (mThursday.Checked)
            {
                days.Add(4);
                daysSB.Append("4,");
            }
            if (mFriday.Checked)
            {
                days.Add(5);
                daysSB.Append("5,");
            }
            if (mSaturday.Checked)
            {
                days.Add(6);
                daysSB.Append("6,");
            }


            //调用JPush api设置Push时间
            JPushInterface.setPushTime(ApplicationContext, days, startime, endtime);

            mEditor = mSettings.edit();
            mEditor.putString(ExampleUtil.PREFS_DAYS, daysSB.ToString());
            mEditor.putInt(ExampleUtil.PREFS_START_TIME, startime);
            mEditor.putInt(ExampleUtil.PREFS_END_TIME, endtime);
            mEditor.commit();
            Toast.makeText(SettingActivity.this, [email protected]_su, Toast.LENGTH_SHORT).show();
        }
        public override void OnCreate()
        {
            Logger.d(TAG, "[ExampleApplication] onCreate");
            base.OnCreate();

            JPushInterface.SetDebugMode(true); // 设置开启日志,发布时请关闭日志
            JPushInterface.Init(this);         // 初始化 JPush
        }
        /// <summary>
        /// init JPush
        /// </summary>
        private void InitJPush()
        {
            JPushInterface.SetDebugMode(true);
            JPushInterface.Init(Application.Context);
            BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(this);

            builder.StatusBarDrawable = Resource.Drawable.jpush_notification_icon;
            JPushInterface.SetPushNotificationBuilder(new Java.Lang.Integer(1), builder);
        }
        /// <summary>
        /// Sets the notification style basic.
        /// </summary>
        private void SetNotificationStyleBasic()
        {
            BasicPushNotificationBuilder builder1 = new BasicPushNotificationBuilder(this);

            builder1.StatusBarDrawable    = Resource.Drawable.ic_launch;
            builder1.NotificationFlags    = (int)NotificationFlags.AutoCancel;         //设置为自动消失
            builder1.NotificationDefaults = (int)NotificationDefaults.All;             // 设置为铃声与震动都要
            JPushInterface.SetPushNotificationBuilder((Integer)1, builder1);
        }
Esempio n. 7
0
        /// <summary>
        /// 设置通知栏样式 - 定义通知栏Layout
        /// </summary>
        private void setStyleCustom()
        {
            CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(PushSetActivity.this, R.layout.customer_notitfication_layout, R.id.icon, R.id.title, R.id.text);

            builder.layoutIconDrawable = R.drawable.ic_launcher;
            builder.developerArg0      = "developerArg2";
            JPushInterface.setPushNotificationBuilder(2, builder);
            Toast.makeText(PushSetActivity.this, "Custom Builder - 2", Toast.LENGTH_SHORT).show();
        }
Esempio n. 8
0
        /// <summary>
        /// 设置通知提示方式 - 基础属性
        /// </summary>
        private void setStyleBasic()
        {
            BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(PushSetActivity.this);

            builder.statusBarDrawable    = R.drawable.ic_launcher;
            builder.notificationFlags    = Notification.FLAG_AUTO_CANCEL;          //设置为点击后自动消失
            builder.notificationDefaults = Notification.DEFAULT_SOUND;             //设置为铃声( Notification.DEFAULT_SOUND)或者震动( Notification.DEFAULT_VIBRATE)
            JPushInterface.setPushNotificationBuilder(1, builder);
            Toast.makeText(PushSetActivity.this, "Basic Builder - 1", Toast.LENGTH_SHORT).show();
        }
Esempio n. 9
0
 public void JPushSetAlias(string aliasName)
 {
     try
     {
         JPushInterface.SetAlias(Application.Context, aliasName, new TagAliasCallback());
     }
     catch (Exception)
     {
     }
 }
        /// <summary>
        /// Sets the notification style custom.
        /// </summary>
        private void SetNotificationStyleCustom()
        {
            CustomPushNotificationBuilder builder2 = new CustomPushNotificationBuilder(this, Resource.Layout.customer_notitfication_layout,
                                                                                       Resource.Id.msgIcon, Resource.Id.msgTitle, Resource.Id.msgContent);

            builder2.StatusBarDrawable = Resource.Drawable.ic_launch;
            // 指定最顶层状态栏小图标
            builder2.LayoutIconDrawable = Resource.Drawable.ic_launch;
            // 指定下拉状态栏时显示的通知图标
            JPushInterface.SetPushNotificationBuilder((Integer)2, builder2);
        }
Esempio n. 11
0
        private void setAddActionsStyle()
        {
            MultiActionsNotificationBuilder builder = new MultiActionsNotificationBuilder(PushSetActivity.this);

            builder.addJPushAction(R.drawable.jpush_ic_richpush_actionbar_back, "first", "my_extra1");
            builder.addJPushAction(R.drawable.jpush_ic_richpush_actionbar_back, "second", "my_extra2");
            builder.addJPushAction(R.drawable.jpush_ic_richpush_actionbar_back, "third", "my_extra3");
            JPushInterface.setPushNotificationBuilder(10, builder);

            Toast.makeText(PushSetActivity.this, "AddActions Builder - 10", Toast.LENGTH_SHORT).show();
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
 public void setAliasWithName(string name)
 {
     if (!string.IsNullOrWhiteSpace(name))
     {
         name = name.Replace("-", "");
         JPushInterface.SetAlias(Application.Context, 0, name);
     }
     else
     {
         JPushInterface.SetAlias(Application.Context, 0, "");
     }
 }
Esempio n. 14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            FormsAppCompatActivity.ToolbarResource   = Resource.Layout.toolbar;
            FormsAppCompatActivity.TabLayoutResource = Resource.Layout.tabs;

            LoadApplication(new App(IoC.Get <SimpleContainer>()));

            JPushInterface.SetDebugMode(true);
            JPushInterface.Init(this);
        }
Esempio n. 15
0
        private void initPushNotification()
        {
            IntentFilter filter = new IntentFilter();

            filter.AddAction(JPushInterface.ActionNotificationOpened);
            filter.AddAction(JPushInterface.ActionNotificationReceived);
            filter.AddAction(JPushInterface.ActionMessageReceived);
            filter.AddAction(JPushInterface.ActionRegistrationId);
            filter.AddAction(JPushInterface.ActionConnectionChange);
            NotificationReceiver receiver = new NotificationReceiver();

            RegisterReceiver(receiver, filter);
            JPushInterface.SetDebugMode(true);
            JPushInterface.Init(this.ApplicationContext);
        }
Esempio n. 16
0
        /// <summary>
        /// hanlder回调函数
        /// </summary>
        /// <param name="msg">Message.</param>
        private void DealMessage(Message msg)
        {
            switch (msg.What)
            {
            case MSG_SET_ALIAS:
                Log.Debug(Tag, "设置aliasname");
                JPushInterface.SetAlias(context, (string)msg.Obj, this);
                break;

            case MSG_SET_TAGS:
                Log.Debug(Tag, "设置tag标签");
                JPushInterface.SetTags(context, (ICollection <string>)msg.Obj, this);
                break;
            }
        }
Esempio n. 17
0
 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);
     }
 }
Esempio n. 18
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            //LoadApplication(new App(IoC.Get<SimpleContainer>()));

            JPushInterface.SetDebugMode(true);
            JPushInterface.Init(ApplicationContext);

            appContext = ApplicationContext;

            //MyTags.Add("123");
            new JPushInterface().SetAliasAndTags(appContext, myAlias, MyTags);
            // Set our view from the "main" layout resource
            //SetContentView (Resource.Layout.Main);
        }
Esempio n. 19
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            FFImageLoading.Forms.Droid.CachedImageRenderer.Init();

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

            FormsAppCompatActivity.ToolbarResource   = Resource.Layout.toolbar;
            FormsAppCompatActivity.TabLayoutResource = Resource.Layout.tabs;

            // https://github.com/Caliburn-Micro/Caliburn.Micro/issues/298
            //this.LoadApplication(new App(IoC.Get<SimpleContainer>()));
            this.LoadApplication(IoC.Get <App>());

            //TODO 调试模式, 发布时请改为 false
            JPushInterface.SetDebugMode(true);
            JPushInterface.Init(this);
        }
Esempio n. 20
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height;
            App.ScreenWidth  = (int)UIScreen.MainScreen.Bounds.Width;
            global::Xamarin.Forms.Forms.Init();
            OxyPlot.Xamarin.Forms.Platform.iOS.PlotViewRenderer.Init();
            LoadApplication(new App());

            //注册apns远程推送
            if (options == null)
            {
                options = new NSDictionary();
            }
            jPushRegister = new JPushInterface();
            jPushRegister.Register(this, options);
            this.RegistLogin(options);

            return(base.FinishedLaunching(app, options));
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height;
            App.ScreenWidth  = (int)UIScreen.MainScreen.Bounds.Width;

            //Xamarin.Calabash.Start();
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            ////注册apns远程推送
            if (options == null)
            {
                options = new NSDictionary();
            }
            jPushRegister = new JPushInterface();
            jPushRegister.Register(this, options);
            this.RegistLogin(options);
            app.ApplicationIconBadgeNumber = 0;
            return(base.FinishedLaunching(app, options));
        }
        public override void OnCreate()
        {
            base.OnCreate();
            #region 极光推送相关
            //注册Jpush
            JPushInterface.SetDebugMode(true);
            JPushInterface.Init(ApplicationContext);
            //设置基本样式
            SetNotificationStyleBasic();
            //自定义推送通知栏样式 test
            SetNotificationStyleCustom();
            //设置保留最近5条通知
            JPushInterface.SetLatestNotificationNumber(ApplicationContext, 5);
            #endregion

            #region imageloader 使用二级缓存
            //var configuration = ImageLoaderConfiguration.CreateDefault(ApplicationContext);//创建默认的ImageLoader配置参数

            //自定义缓存路径
            var          cachePath = Android.OS.Environment.ExternalStorageDirectory.ToString() + "/" + "eldyoungCommCenter/Cache/HeadImage/";
            Java.IO.File file      = new Java.IO.File(cachePath);
            if (!file.Exists())
            {
                file.Mkdirs();                                                                     // 创建文件夹
            }
            File cacheDir      = StorageUtils.GetOwnCacheDirectory(ApplicationContext, cachePath); //自定义缓存路径
            var  configuration = new ImageLoaderConfiguration.Builder(ApplicationContext).MemoryCacheExtraOptions(480, 800)
                                 .ThreadPoolSize(3).ThreadPriority(Thread.NormPriority - 2).DenyCacheImageMultipleSizesInMemory()
                                 .MemoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)).MemoryCacheSize(2 * 1024 * 1024).DiskCacheSize(50 * 1024 * 1024)
                                 .DiskCacheFileNameGenerator(new Md5FileNameGenerator()).TasksProcessingOrder(QueueProcessingType.Lifo).DiskCacheFileCount(100)
                                 .DiskCache(new UnlimitedDiskCache(cacheDir)).DefaultDisplayImageOptions(DisplayImageOptions.CreateSimple()).ImageDownloader(new BaseImageDownloader(ApplicationContext, 5 * 1000, 30 * 1000))
                                 .Build();
            ImageLoader.Instance.Init(configuration);

            #endregion

            #region 百度地图使用
            SDKInitializer.Initialize(ApplicationContext);
            #endregion
        }
        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;
            }
        }
Esempio n. 24
0
        protected override void OnPause()
        {
            base.OnPause();

            JPushInterface.OnPause(this);
        }
 // 初始化 JPush。如果已经初始化,但没有登录成功,则执行重新登录。
 private void init()
 {
     JPushInterface.Init(ApplicationContext);
 }
        /// <summary>
        /// 处理设置tag
        ///
        /// </summary>
        public virtual void handleAction(Context context, int sequence, TagAliasBean tagAliasBean)
        {
            init(context);
            if (tagAliasBean == null)
            {
                Logger.w(TAG, "tagAliasBean was null");
                return;
            }
            put(sequence, tagAliasBean);
            if (tagAliasBean.isAliasAction)
            {
                switch (tagAliasBean.action)
                {
                case ACTION_GET:
                    JPushInterface.GetAlias(context, sequence);
                    break;

                case ACTION_DELETE:
                    JPushInterface.DeleteAlias(context, sequence);
                    break;

                case ACTION_SET:
                    JPushInterface.SetAlias(context, sequence, tagAliasBean.alias);
                    break;

                default:
                    Logger.w(TAG, "unsupport alias action type");
                    return;
                }
            }
            else
            {
                switch (tagAliasBean.action)
                {
                case ACTION_ADD:
                    JPushInterface.AddTags(context, sequence, tagAliasBean.tags);
                    break;

                case ACTION_SET:
                    JPushInterface.SetTags(context, sequence, tagAliasBean.tags);
                    break;

                case ACTION_DELETE:
                    JPushInterface.DeleteTags(context, sequence, tagAliasBean.tags);
                    break;

                case ACTION_CHECK:
                    //一次只能check一个tag
                    string tag = (string)tagAliasBean.tags[0];
                    JPushInterface.CheckTagBindState(context, sequence, tag);
                    break;

                case ACTION_GET:
                    JPushInterface.GetAllTags(context, sequence);
                    break;

                case ACTION_CLEAN:
                    JPushInterface.CleanTags(context, sequence);
                    break;

                default:
                    Logger.w(TAG, "unsupport tag action type");
                    return;
                }
            }
        }
 public virtual void handleAction(Context context, int sequence, string mobileNumber)
 {
     put(sequence, mobileNumber);
     Logger.d(TAG, "sequence:" + sequence + ",mobileNumber:" + mobileNumber);
     JPushInterface.SetMobileNumber(context, sequence, mobileNumber);
 }
Esempio n. 28
0
 public void UserId(string data)
 {
     name = name.Replace("-", "");
     JPushInterface.SetAlias(Application.Context, 0, name);
 }
Esempio n. 29
0
 public void setAliasWithName(string name)
 {
     JPushInterface.SetAlias(Application.Context, 0, name);
 }
Esempio n. 30
0
 public static string getDeviceId(Context context)
 {
     return(JPushInterface.GetUdid(context));
 }