コード例 #1
0
ファイル: App.xaml.cs プロジェクト: FgoDt/AcFunVideo
        private async void InitPushService()
        {
            try
            {
                if (Channel != null)
                {
                    Channel.PushNotificationReceived -= OnPushNotificationReceived;
                    Channel = null;
                }
                Channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

                Channel.PushNotificationReceived += OnPushNotificationReceived;
                var timeout = Config.GetValue(ConfigSetting.PushServiceExpiration, 0L, false).TimeStampToDate();
                if (timeout <= DateTime.Now)
                {
                    PushService.InitBmob("e9c75afb85827f7eda486d8eaa5eb304", "c88dc50c5af870db43d4de302cce50d5");
                    PushService.InitPushService(Channel, "Push", () =>
                    {
                        Config.SetValue(ConfigSetting.PushServiceExpiration, Channel.ExpirationTime.LocalDateTime.GetTimeStampSeconds(), false);
                    });
                }
            }
            catch (Exception ex)
            {
            }
        }