Suche…


Bemerkungen

AWS Simple Benachrichtigungsdienst Lingo:

Endpunkt - Der Endpunkt kann ein Telefon, eine E-Mail-Adresse oder was auch immer sein. Dies ist, was AWS SNS mit einer Benachrichtigung zurückschlagen kann

Thema - Im Wesentlichen eine Gruppe, die alle Ihre Endpunkte enthält

Abonnieren - Sie melden sich bei Ihrem Telefon / Client an, um Benachrichtigungen zu erhalten

Generisches Pushbenachrichtigungs-Lingo:

APNS - Apple Push Benachrichtigungsdienst. Apple kann als einziger Push-Benachrichtigungen senden. Deshalb versorgen wir unsere App mit dem richtigen Zertifikat. Wir stellen AWS SNS das Zertifikat zur Verfügung, das uns von Apple erteilt wird, um SNS zu autorisieren, in unserem Namen eine Benachrichtigung an APNS zu senden.

GCM - Google Cloud Messaging ist APNS sehr ähnlich. Nur Google kann Push-Benachrichtigungen direkt versenden. Also registrieren wir zuerst unsere App in GCM und übergeben unser Token an AWS SNS. SNS kümmert sich um alles, was mit GCM zu tun hat und die Daten überträgt.

iOS-Beispiel

  1. Sie benötigen ein Entwicklungsgerät
  2. Wechseln Sie zu Ihrem Apple Developer Account und erstellen Sie ein Bereitstellungsprofil mit aktivierten Push-Benachrichtigungen
  3. Sie werden irgendeine Art von Art und Weise müssen Sie Ihr Telefon (AWS, Azure..etc) benachrichtigen Wir AWS nutzen werden hier
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    global::Xamarin.Forms.Forms.Init();

   //after typical Xamarin.Forms Init Stuff

   //variable to set-up the style of notifications you want, iOS supports 3 types

   var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
              UIUserNotificationType.Alert |
              UIUserNotificationType.Badge |
              UIUserNotificationType.Sound,
              null );  

       
        //both of these methods are in iOS, we have to override them and set them up
        //to allow push notifications

        app.RegisterUserNotificationSettings(pushSettings);  //pass the supported push notifications settings to register app in settings page

     
}

public override async void RegisteredForRemoteNotifications(UIApplication application, NSData token)
    {
        AmazonSimpleNotificationServiceClient snsClient = new AmazonSimpleNotificationServiceClient("your AWS credentials here");

        // This contains the registered push notification token stored on the phone. 
        var deviceToken = token.Description.Replace("<", "").Replace(">", "").Replace(" ", ""); 

        if (!string.IsNullOrEmpty(deviceToken))
        {
            //register with SNS to create an endpoint ARN, this means AWS can message your phone
            var response = await snsClient.CreatePlatformEndpointAsync(
            new CreatePlatformEndpointRequest
            {
                Token = deviceToken,
                PlatformApplicationArn = "yourARNwouldgohere" /* insert your platform application ARN here */
            });

            var endpoint = response.EndpointArn;

            //AWS lets you create topics, so use subscribe your app to a topic, so you can easily send out one push notification to all of your users
            var subscribeResponse = await snsClient.SubscribeAsync(new SubscribeRequest
            {
                TopicArn = "YourTopicARN here",
                Endpoint = endpoint,
                Protocol = "application"

            });

        }

    }


Modified text is an extract of the original Stack Overflow Documentation
Lizenziert unter CC BY-SA 3.0
Nicht angeschlossen an Stack Overflow