一直到最后一步,会看到证书:
class AppDelegate { ... func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let center = UNUserNotificationCenter.current() center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in // Enable or disable features based on authorization. } application.registerForRemoteNotifications() return true } func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}) print(deviceTokenString) } ...
... var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, "push-cert.p12", "Hello-12345"); // Create a new broker var apnsBroker = new ApnsServiceBroker(config); // Wire up events apnsBroker.OnNotificationFailed += (notification, aggregateEx) => { aggregateEx.Handle(ex => { // See what kind of exception it was to further diagnose if (ex is ApnsNotificationException) { var notificationException = (ApnsNotificationException) ex; // Deal with the failed notification var apnsNotification = notificationException.Notification; var statusCode = notificationException.ErrorStatusCode; _log.ErrorFormat($"Apple Notification Failed: ID={apnsNotification.Identifier}, Code={statusCode}"); } else { // Inner exception might hold more useful information like an ApnsConnectionException _log.ErrorFormat($"Apple Notification Failed for some unknown reason : {ex.InnerException}"); } // Mark it as handled return true; }); }; apnsBroker.OnNotificationSucceeded += (notification) => { _log.InfoFormat("Apple Notification Sent!"); }; // Start the broker apnsBroker.Start(); // Queue a notification to send apnsBroker.QueueNotification(new ApnsNotification { DeviceToken = "58AA314A317D72AE83413F9C9FA6201D2573FAE472A40D72D0E528E7D0F51DED", Payload = JObject.Parse("{" + "\"aps\":{\"alert\":\"Hello PushSharp!\"}" + "}") }); // Stop the broker, wait for it to finish // This isn't done after every message, but after you're // done with the broker apnsBroker.Stop(); ...