Compartilhar via


AccessoryManager.GetNextTriggerDetails Método

Definição

Obtém os próximos detalhes do gatilho que contêm as informações sobre o gatilho, incluindo o tipo de notificação, o nome de exibição e a hora criada.

public:
 static IAccessoryNotificationTriggerDetails ^ GetNextTriggerDetails();
 static IAccessoryNotificationTriggerDetails GetNextTriggerDetails();
public static IAccessoryNotificationTriggerDetails GetNextTriggerDetails();
function getNextTriggerDetails()
Public Shared Function GetNextTriggerDetails () As IAccessoryNotificationTriggerDetails

Retornos

Contém informações sobre o gatilho.

Requisitos do Windows

Funcionalidades do aplicativo
accessoryManager

Exemplos

Determine o tipo real da notificação. Não é necessário dar suporte a todos os tipos, mas o exemplo a seguir pressupõe que o acessório esteja interessado em tudo.

// MyBackgroundTask.cs

       public async void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
            INotificationTriggerDetails notificationTriggerDetails = 
             AccessoryManager.NextTriggerDetails();
            while (notificationTriggerDetails != null) 
// get rid of while loop in case you would like to process one notification at a time. 
//  You have to use ProcessingTriggerDetailsCompleted to indicate that you are done with this instance of the trigger
            {
                switch (notificationTriggerDetails.NotificationType)
                {
                    case NotificationType.PhoneCall:
                        IPhoneNotificationTriggerDetails phoneCallTriggerDetails = notificationTriggerDetails as IPhoneNotificationTriggerDetails;
                        string callMsg = "Got Phone Notification for ";
                        switch (phoneCallTriggerDetails.PhoneNotificationType)
                        {
                            case PhoneNotificationType.NewCall:
                            case PhoneNotificationType.CallChanged:
                                callMsg +=  
                            phoneCallTriggerDetails.PhoneNotificationType.ToString();
                                callMsg += " having direction " + 
                            phoneCallTriggerDetails.CallDetails.CallDirection.ToString();
                                callMsg += " from " + 
                            phoneCallTriggerDetails.CallDetails.PhoneNumber + "(" + 
                            phoneCallTriggerDetails.CallDetails.ContactName + ") ";
                                callMsg += "Media type " + 
                            phoneCallTriggerDetails.CallDetails.CallMediaType + "," + 
                            phoneCallTriggerDetails.CallDetails.CallTransport;
                                callMsg += " with State " + 
                            phoneCallTriggerDetails.CallDetails.State.ToString();
                                callMsg += " and Call id " + 
                            phoneCallTriggerDetails.CallDetails.CallId;
                                Debug.WriteLine(callMsg);

//Based on input from the device use the following methods to take action on the call
//Accept Call
                                //AccessoryManager.AcceptPhoneCall(phoneCall.CallDetails.CallId);

//Reject With SMS
//IReadOnlyList<ITextResponse> listResponses = phoneCall.CallDetails.PresetTextResponses;
//string response = listResponses[0].Content;

// AccessoryManager.RejectPhoneCall(phoneCall.CallDetails.CallId, listResponses[0].Id);
// Reject Call
// AccessoryManager.RejectPhoneCall(phoneCall.CallDetails.CallId);
                                break;

                            case PhoneNotificationType.PhoneCallAudioEndpointChanged:
                            case PhoneNotificationType.PhoneMuteChanged:
                                callMsg += phoneCallTriggerDetails.PhoneLineChangedId;
                                callMsg += 
                            phoneCallTriggerDetails.PhoneNotificationType.ToString();
                                Debug.WriteLine(callMsg);

                                break;
                        }
                        break;
                    case NotificationType.Toast:
                        IToastNotificationTriggerDetails toast = 
                         notificationTriggerDetails as IToastNotificationTriggerDetails;
                        Debug.WriteLine("Got toast from :" + toast.AppDisplayName + " AppId: " + toast.AppId + " Header: " + toast.Text1 + " Body: " + toast.Text2 + " IsGhost:" + toast.SuppressPopup + " at: " + toast.TimeCreated);
                        break;
                    case NotificationType.Alarm:
                        IAlarmNotificationTriggerDetails alarmTriggerDetails = notificationTriggerDetails as IAlarmNotificationTriggerDetails;
                        Debug.WriteLine("Got Alarm :" + alarmTriggerDetails.AppDisplayName + " AppId: " + alarmTriggerDetails.AppId + " Title: " + alarmTriggerDetails.Title + " IsActive: " + alarmTriggerDetails.IsActive + " TimeStamp:" + alarmTriggerDetails.Timestamp);
                        break;
                    case NotificationType.AppUninstalled:
                        INotificationTriggerDetails appUninstallTriggerDetails = notificationTriggerDetails as INotificationTriggerDetails;
                        Debug.WriteLine("Got Application Uninstall Trigger for App: " + appUninstallTriggerDetails.AppDisplayName + " AppId: " + appUninstallTriggerDetails.AppId + " at" + appUninstallTriggerDetails.TimeCreated);
                        break;
                    case NotificationType.Email:
                    //get the Email data from trigger details
                    case NotificationType.Sms:
                        //get the SMS details
                        break;
                    default:
                        Debug.WriteLine("Not supported notification type");
                        break;
                }
                //TODO: Make connection and send the data to the accessory

                //Mark the trigger details as completed processing

AccessoryManager.ProcessingTriggerDetailsCompleted(notificationTriggerDetails);

                notificationTriggerDetails = 
                 AccessoryManager.NextTriggerDetails();
            }
            deferral.Complete();
        }
    }

Comentários

O AccessoryManager ativará o BackgroundTask quando encontrar uma notificação que o acessório registrou para ver. O BackgroundTask é fornecido um IBackgroundTaskInstance que tem uma propriedade TriggerDetails que contém iNotificationTriggerDetails. Observe que o AccessoryManager do telefone fornece apenas os dados; ele não controla como as coisas são renderizadas no acessório. Isso tudo cabe ao desenvolvedor acessório.

Chamar essa API requer que os recursos ID_CAP_SMS e ID_CAP_SMS_COMPANION sejam especificados no manifesto do aplicativo.

Aplica-se a