Пример #1
0
        private async void PushManager_StateChanged(PushManager sender, PushManagerStateChangedEventArgs args)
        {
            if (args.NEW_STATE == PushManagerState.INITIALIZED)
            {
                PushNotificationChannel channel = PushManager.INSTANCE.GetChannel();
                channel.PushNotificationReceived -= WNS_PushNotificationReceived;
                channel.PushNotificationReceived += WNS_PushNotificationReceived;

                // Setup done, now send an updated list of all push accounts:
                if (PushManager.ShouldUpdatePushForAccounts())
                {
                    await PushManager.INSTANCE.InitPushForAccountsAsync();
                }
                else
                {
                    Logger.Info("No need to update push accounts on the push server.");
                }
            }
            else if (args.NEW_STATE == PushManagerState.DEAKTIVATED && args.OLD_STATE == PushManagerState.INITIALIZED)
            {
                // Setup done, now send an updated list of all push accounts:
                if (PushManager.ShouldUpdatePushForAccounts())
                {
                    await PushManager.INSTANCE.InitPushForAccountsAsync();
                }
                else
                {
                    Logger.Info("No need to update push accounts on the push server.");
                }
            }
        }
Пример #2
0
        private async void PushManager_StateChanged(PushManager sender, PushManagerStateChangedEventArgs args)
        {
            if (args.NEW_STATE == PushManagerState.INITIALIZED)
            {
                // Setup done, now send an updated list of all push accounts:
                if (PushManager.ShouldUpdatePushForAccounts())
                {
                    await PushManager.INSTANCE.InitPushForAccountsAsync();
                }
                else
                {
                    Logger.Info("No need to update push accounts on the push server.");
                }

                // Inform the clients that the PushManager initialized successfully:
                foreach (ClientConnectionHandler c in ConnectionHandler.INSTANCE.GetClients())
                {
                    c.client.PUSH_MANAGER.OnPushManagerInitialized();
                }
            }
            else if (args.NEW_STATE == PushManagerState.DEAKTIVATED)
            {
                if (args.OLD_STATE == PushManagerState.INITIALIZED)
                {
                    // Setup done, now send an updated list of all push accounts:
                    if (PushManager.ShouldUpdatePushForAccounts())
                    {
                        await PushManager.INSTANCE.InitPushForAccountsAsync();
                    }
                    else
                    {
                        Logger.Info("No need to update push accounts on the push server.");
                    }
                }
                // Inform the clients that the PushManager got disabled:
                foreach (ClientConnectionHandler c in ConnectionHandler.INSTANCE.GetClients())
                {
                    c.client.PUSH_MANAGER.OnPushManagerInitialized();
                }
            }
        }