HTTP / 2 oder Wie ich PUSH-Benachrichtigungen unter iOS bekämpft habe

Hallo zusammen. Vor kurzem erhielten meine Projekte keine Push-Benachrichtigungen mehr auf iOS-Geräten. Nach dem "googeln" -Prozess stellte sich heraus, dass Push-Benachrichtigungen für "Äpfel" nun über das http / 2-Protokoll gesendet werden sollten.





HEADERS
  - END_STREAM
  + END_HEADERS
  :method = POST
  :scheme = https
  :path = /3/device/00fc13adff785122b4ad28809a3420982341241421348097878e577c991de8f0
  host = api.development.push.apple.com
  authorization = bearer eyAia2lkIjogIjhZTDNHM1JSWDciIH0.eyAiaXNzIjogIkM4Nk5WOUpYM0QiLCAiaWF0I
 jogIjE0NTkxNDM1ODA2NTAiIH0.MEYCIQDzqyahmH1rz1s-LFNkylXEa2lZ_aOCX4daxxTZkVEGzwIhALvkClnx5m5eAT6
 Lxw7LZtEQcH6JENhJTMArwLf3sXwi
  apns-id = eabeae54-14a8-11e5-b60b-1697f925ec7b
  apns-expiration = 0
  apns-priority = 10
  apns-topic = <MyAppTopic>
DATA
  + END_STREAM
    { "aps" : { "alert" : "Hello" } }
Listing 8-3 shows a sample request constructed for a certificate that contains multiple topics.


      
      



Hier ist ein Beispiel für eine Anforderung über das http / 2-Protokoll





. ASP.NET Framework IIS. Windows 2012R2. , HTTP/2 . - . . . "". ANDROID .





ASP.NET Core. ASP.NET Core Linux. Linux HTTP/2.





ASP.NET Core .





ASP.NET Core.





 public class dotAPNSService : IDisposable
    {
        public event EventHandler OnTokenExpiredHandler;
        private ApnsJwtOptions options = null;

        public dotAPNSService(string bundle)
        {
            options = new ApnsJwtOptions()
            {
                BundleId = bundle, //      com.org.test
                CertContent = "       ",//https://developer.apple.com/account/resources/authkeys/list
                KeyId = "  ",//https://developer.apple.com/account/resources/authkeys/list
                TeamId = "  "//https://developer.apple.com/account/resources/authkeys/list
            };
        }

        public void SendNotifications(String[] deviceTokens, String title, String body)
        {
            if (deviceTokens == null || deviceTokens.Length <= 0)
            {
                return;
            }

            if (String.IsNullOrEmpty(title))
            {
                return;
            }

            if (String.IsNullOrEmpty(body))
            {
                return;
            }

            // once you've gathered all the information needed and created an options instance, it's time to call
            var apns = ApnsClient.CreateUsingJwt(new HttpClient( ), options);

            // start the process     
            foreach (String deviceToken in deviceTokens)
            {
                var push = new ApplePush(ApplePushType.Alert)
                    .AddAlert(title, body)
                    .AddToken(deviceToken);

                Send(apns, push, deviceToken);
            }
        }
}
      
      



!!! . . .





NET.Core Docker. VPS REG.RU. VPS.





! . . . .













Visual Studio





.





Dann stellt es einfach über SSH eine Verbindung zu unserem Server her. Zugangsschlüssel werden Ihnen per E-Mail zugeschickt.





Geben Sie den Befehl ein, um Ihr Projekt über Docker zu starten





docker run -d -p 80:80/tcp /
      
      



Nach diesem Befehl ist Ihr Projekt unter http: // server ipaddress / verfügbar





Außerdem sende ich in allen Projekten einfach eine Post-Anfrage mit einer Reihe von Empfänger-Token, Header und Nachricht an diese Adresse. Alles geht und kommt einfach super schnell.





PS Sie können einen Domainnamen in den reg.ru-Einstellungen binden.





Ergebnis

Im Moment werden alle Push-Nachrichten normal ausgelöst. Es wurden keine Probleme mit einem solchen Bündel gefunden. Es scheint sogar, dass Push-Benachrichtigungen viel schneller verschwinden als zuvor. Ich hoffe, mein Artikel hilft denen, die mit einem ähnlichen Problem konfrontiert waren.








All Articles