教學課程:使用 Azure 通知中樞將通知推送至 iOS 應用程式Tutorial: Push notifications to iOS apps using Azure Notification Hubs

在本教學課程中,您會使用 Azure 通知中樞將通知推送至 iOS 應用程式。In this tutorial, you use Azure Notification Hubs to push notifications to an iOS application. 您會使用 Apple Push Notification Service (APNS),建立可接收推播通知的空白 iOS 應用程式。You create a blank iOS app that receives push notifications by using the Apple Push Notification service (APNs).

在本教學課程中,您會執行下列步驟:In this tutorial, you take the following steps:

  • 產生憑證簽署要求檔案Generate the certificate signing request file
  • 為您的應用程式要求推播通知Request your app for push notifications
  • 建立應用程式的佈建設定檔Create a provisioning profile for the app
  • 針對 iOS 推播通知設定您的通知中樞Configure your notification hub for iOS push notifications
  • 將您的 iOS 應用程式連線至通知中樞Connect your iOS app to notification hubs
  • 傳送測試推播通知Send test push notifications
  • 確認您的應用程式可接收通知Verify that your app receives notifications

您可以在 GitHub上找到本教學課程的完整程式碼。The completed code for this tutorial can be found on GitHub.

必要條件Prerequisites

完成本教學課程是參加 iOS app 所有其他通知中樞教學課程的先決條件。Completing this tutorial is a prerequisite for all other Notification Hubs tutorials for iOS apps.

產生憑證簽署要求檔案Generate the certificate-signing request file

Apple Push Notification Service (APNs) 使用憑證來驗證您的通知服務。The Apple Push Notification Service (APNs) uses certificates to authenticate your push notifications. 遵循下列指示來建立必要的推播憑證,以便傳送和接收通知。Follow these instructions to create the necessary push certificate to send and receive notifications. 如需這些概念的詳細資訊,請參閱 Apple Push Notification Service 官方文件。For more information on these concepts, see the official Apple Push Notification Service documentation.

產生憑證簽署要求 (CSR) 檔案,Apple 會用此檔案來產生簽署的推播憑證。Generate the Certificate Signing Request (CSR) file, which Apple uses to generate a signed push certificate.

  1. 在您的 Mac 上,執行「鑰匙圈存取」工具。On your Mac, run the Keychain Access tool. 此工具可從啟動控制板上的 [公用程式] 資料夾或 [其他] 資料夾開啟。It can be opened from the Utilities folder or the Other folder on the Launchpad.

  2. 選取 [金鑰鏈存取] ,並展開 [憑證助理] ,然後選取 [從憑證授權單位要求憑證] 。Select Keychain Access, expand Certificate Assistant, and then select Request a Certificate from a Certificate Authority.

    使用金鑰鏈存取要求新憑證

  3. 選取您的使用者電子郵件地址,輸入一般名稱值,並確定您已指定 [儲存至磁碟] ,然後選取 [繼續] 。Select your User Email Address, enter your Common Name value, make sure that you specify Saved to disk, and then select Continue. 請將 [CA 電子郵件地址] 留空,因為這不是必要資訊。Leave CA Email Address blank as it isn't required.

    必要的憑證資訊

  4. 在 [另存新檔] 中輸入 CSR 檔案的名稱,在 [位置] 中選取位置,然後選取 [儲存] 。Enter a name for the CSR file in Save As, select the location in Where, and then select Save.

    選擇憑證的檔案名稱

    此動作會在選取的位置儲存 CSR 檔案。This action saves the CSR file in the selected location. 預設位置是桌面The default location is Desktop. 請記住為檔案選擇的位置。Remember the location chosen for the file.

接著,向 Apple 註冊您的應用程式,並啟用推播通知,然後上傳這個匯出的 CSR 建立推播憑證。Next, register your app with Apple, enable push notifications, and upload the exported CSR to create a push certificate.

針對推播通知註冊應用程式Register your app for push notifications

若要將通知推送至 iOS 應用程式,請向 Apple 註冊您的應用程式,並註冊進行推播通知。To push notifications to an iOS app, register your application with Apple and also register for push notifications.

  1. 如果您尚未註冊應用程式,請瀏覽至 Apple Developer Center 上的 iOS 佈建入口網站If you haven't already registered your app, browse to the iOS Provisioning Portal at the Apple Developer Center. 然後,以您的 Apple ID 登入,並依序選取 [識別碼] 、[應用程式識別碼] 、[+] 來註冊新的應用程式。After that, sign in with your Apple ID, select Identifiers, select App IDs, and finally select + to register a new app.

    iOS 佈建入口網站應用程式識別碼頁面

  2. 將新應用程式的下列三個值予以更新,然後選取 [繼續] :Update the following three values for your new app, and then select Continue:

    • 名稱:在 [應用程式識別碼描述] 區段的 [名稱] 方塊中輸入應用程式的描述性名稱。Name: Type a descriptive name for your app in the Name box in the App ID Description section.

    • 套件組合識別碼:在 [明確的應用程式識別碼] 區段中,以應用程式分發指南 (英文) 中所提的 <Organization Identifier>.<Product Name> 形式輸入 [套件組合識別碼] 。Bundle Identifier: In the Explicit App ID section, enter a Bundle Identifier of the form <Organization Identifier>.<Product Name> as mentioned in the App Distribution Guide. [組織識別碼] 和 [產品名稱] 值必須符合當您建立 Xcode 專案時使用的組織識別碼和產品名稱。The Organization Identifier and Product Name values must match the organization identifier and product name you use when you create your Xcode project. 在下列螢幕擷取畫面中,NotificationHubs 值會作為組織識別碼,GetStarted 值會作為產品名稱。In the following screenshot, the NotificationHubs value is used as an organization identifier and the GetStarted value is used as the product name. 請確定套件組合識別碼值符合您 Xcode 專案中的值,好讓 Xcode 使用正確的發行設定檔。Make sure the Bundle Identifier value matches the value in your Xcode project, so that Xcode will use the correct publishing profile.

    • 推播通知:勾選 [應用程式服務] 區段中的 [推播通知] 選項。Push Notifications: Check the Push Notifications option in the App Services section.

      註冊新應用程式識別碼的表單

      此動作會產生您的應用程式識別碼,並要求您確定此資訊。This action generates your App ID and requests that you confirm the information. 選取 [註冊] 確認新的應用程式識別碼。Select Register to confirm the new App ID.

      選取 [註冊] 之後,您會看見 [註冊完成] 畫面,如下圖所示。After you select Register, you see the Registration complete screen as shown in the following image. 選取 [完成] 。Select Done.

      應用程式識別碼註冊完成並顯示權利

  3. 在 Developer Center 的 [應用程式識別碼] 底下,找出您建立的應用程式識別碼,並選取該資料列。In the Developer Center, under App IDs, locate the app ID that you created and select its row.

    應用程式識別碼清單

    選取應用程式識別碼以顯示應用程式詳細資料,然後選取底部的 [編輯] 按鈕。Select the app ID to display the app details, and then select the Edit button at the bottom.

    編輯應用程式識別碼頁面

  4. 捲動到畫面底部,然後選取 [開發推播 SSL 憑證] 區段下方的 [建立憑證] 按鈕。Scroll to the bottom of the screen and select the Create Certificate button under the Development Push SSL Certificate section.

    為應用程式識別碼建立憑證的按鈕

    您現在會看到新增 iOS 憑證助理。You now see the Add iOS Certificate assistant.

    注意

    本教學課程使用開發憑證。This tutorial uses a development certificate. 註冊生產憑證時,將使用同一個程序。The same process is used when registering a production certificate. 只要確定在傳送通知時使用相同的憑證類型即可。Just make sure that you use the same certificate type when sending notifications.

  5. 選取 [選擇檔案] ,瀏覽到您在第一個工作中儲存 CSR 檔案的位置,然後選取 [產生] 。Select Choose File, browse to the location where you saved the CSR file from the first task, and then select Generate.

    產生的憑證 CSR 上傳頁面

  6. 在入口網站建立憑證之後,請選取 [下載] 按鈕,然後選取 [完成] 。After the portal creates the certificate, select the Download button and then select Done.

    產生的憑證 CSR 下載頁面

    這會下載憑證並將其儲存到您電腦中的 [下載] 資料夾。The certificate is downloaded and saved to your computer in your Downloads folder.

    在 [下載] 資料夾中找出憑證檔案

    注意

    依預設,下載的開發憑證會名為 aps_development.cerBy default, the downloaded development certificate is named aps_development.cer.

  7. 選取下載的推播憑證 aps_development.cerSelect the downloaded push certificate aps_development.cer.

    此動作會將新的憑證安裝在金鑰鏈中,如下圖所示:This action installs the new certificate in the Keychain, as shown in the following image:

    顯示新憑證的金鑰鏈存取憑證清單

    注意

    雖然憑證中的名稱可能會不同,不過名稱會加上 Apple Development iOS Push Services 前置詞。Although the name in your certificate might be different, the name will be prefixed with Apple Development iOS Push Services.

  8. 在 Keychain Access 中,以滑鼠右鍵按一下您在 [憑證] 類別中建立的新推播憑證。In Keychain Access, right-click the new push certificate that you created in the Certificates category. 選取 [匯出] 、為檔案命名、選取 [.p12] 格式,然後選取 [儲存] 。Select Export, name the file, select the .p12 format, and then select Save.

    以 p12 格式匯出憑證

    記下匯出的 .p12 憑證的檔案名稱和位置。Make a note of the file name and location of the exported .p12 certificate. 其可用來啟用 APNs 驗證功能。They are used to enable authentication with APNs.

    注意

    本教學課程會建立名為 QuickStart.p12 的檔案。This tutorial creates a file named QuickStart.p12. Your file name and location might be different.Your file name and location might be different.

建立應用程式的佈建設定檔Create a provisioning profile for the app

  1. iOS 佈建入口網站中,依序選取 [佈建設定檔] 和 [全部] ,然後選取 [+] 來建立新的設定檔。In the iOS Provisioning Portal, select Provisioning Profiles, select All, and then select + to create a new profile. 您會看到 [新增 iOS 佈建設定檔] 精靈。You see the Add iOS Provisioning Profile wizard.

    佈建設定檔清單

  2. 選取 [開發] 下的 [iOS 應用程式開發] 作為佈建設定檔類型,然後選取 [繼續] 。Select iOS App Development under Development as the provisioning profile type, and select Continue.

  3. 接著,從 [應用程式識別碼] 下拉式清單選取您建立的應用程式識別碼,然後選取 [繼續] 。Next, select the app ID you created from the App ID drop-down list, and select Continue.

    選取應用程式識別碼

  4. 在 [選取憑證] 視窗中,選取用於程式碼簽署的一般開發憑證,然後選取 [繼續] 。In the Select certificates window, select your usual development certificate that you used for code signing, and select Continue. 此憑證不是您建立的推播憑證。This certificate isn't the push certificate you created.

    選取憑證

  5. 接下來,選取要用來測試的裝置,然後選取 [繼續] 。Next, select the devices to use for testing, and select Continue.

    選取裝置

  6. 最後,在 [設定檔名稱] 中為設定檔挑選名稱,然後選取 [產生] 。Finally, pick a name for the profile in Profile Name, and select Generate.

    選擇佈建設定檔名稱

  7. 當新的佈建設定檔建立好時,將其選取以下載並安裝在 Xcode 開發電腦上。When the new provisioning profile is created, choose to download and install it on your Xcode development machine. 然後選取 [完成] 。Then select Done.

    下載佈建設定檔

建立通知中樞Create a notification hub

在本節中,您會建立通知中樞,並使用您先前建立的 .p12 推播憑證,設定以 APNs 進行驗證的機制。In this section, you create a notification hub and configure authentication with APNs by using the .p12 push certificate that you previously created. 如果您想要使用已經建立的通知中樞,可以跳至步驟 5。If you want to use a notification hub that you've already created, you can skip to step 5.

  1. 登入 Azure 入口網站Sign in to the Azure portal.

  2. 選取左功能表上的 [所有服務] ,然後選取 [行動] 區段中的 [通知中樞] 。Select All services on the left menu, and then select Notification Hubs in the Mobile section. 選取服務名稱旁邊的星號圖示,將服務加到左功能表上的 [我的最愛] 區段。Select the star icon next to the service name to add the service to the FAVORITES section on the left menu. 在 [通知中樞] 加到 [我的最愛] 之後,在左功能表上予以選取。After you add Notification Hubs to FAVORITES, select it on the left menu.

    Azure 入口網站 - 選取通知中樞

  3. 在 [通知中樞] 頁面上,選取工具列上的 [新增] 。On the Notification Hubs page, select Add on the toolbar.

    通知中樞 - 新增工具列按鈕

  4. 在 [通知中樞] 頁面上,執行下列步驟:On the Notification Hub page, do the following steps:

    1. 在 [通知中樞] 中輸入名稱。Enter a name in Notification Hub.

    2. 在 [建立新的命名空間] 中輸入名稱。Enter a name in Create a new namespace. 命名空間包含一或多個中樞。A namespace contains one or more hubs.

    3. 從 [位置] 下拉式清單方塊選取值。Select a value from the Location drop-down list box. 此值會指定您要在其中建立中樞的位置。This value specifies the location in which you want to create the hub.

    4. 在 [資源群組] 中選取現有的資源群組,或建立一個新群組。Select an existing resource group in Resource Group, or create a name for a new resource group.

    5. 選取 [建立] 。Select Create.

      Azure 入口網站 - 設定通知中樞屬性

  5. 選取 [通知] (鈴鐺圖示),然後選取 [前往資源] 。Select Notifications (the bell icon), and then select Go to resource. 您也可以重新整理 [通知中樞] 頁面中的清單,然後選取您的中樞。You can also refresh the list on the Notification Hubs page and select your hub.

    Azure 入口網站 - 通知 -> 前往資源

  6. 從清單中選取 [存取原則] 。Select Access Policies from the list. 請記下您可使用的兩個連接字串。Note that the two connection strings are available to you. 您稍後需要用到這些連接字串來處理推播通知。You'll need them later to handle push notifications.

    重要

    「請勿」 在應用程式中使用 DefaultFullSharedAccessSignature 原則。Do not use the DefaultFullSharedAccessSignature policy in your application. 這只能在後端使用。This is meant to be used in your back end only.

    Azure 入口網站 - 通知中樞連接字串

使用 APNs 資訊設定您的通知中樞Configure your notification hub with APNs information

  1. 在 [Notification Services] 下,選取 [Apple (APNS)] 。Under Notification Services, select Apple (APNS).

  2. 選取 [憑證] 。Select Certificate.

  3. 選取 [檔案] 圖示。Select the file icon.

  4. 選取您先前匯出的 .p12 檔案。Select the .p12 file that you exported earlier.

  5. 指定正確的密碼。Specify the correct password.

  6. 選取 [沙箱] 模式。Select Sandbox mode. 只有在您想傳送推播通知給從市集購買應用程式的使用者時,才可使用 [生產] 模式。Use the Production mode only if you want to send push notifications to users who purchased your app from the store.

    在 Azure 入口網站中設定 APNS 憑證

您現在已使用 APNs 來設定通知中樞。You've now configured your notification hub with APNs. 您也擁有可用來註冊應用程式和傳送推播通知的連接字串。You also have the connection strings to register your app and send push notifications.

將您的 iOS 應用程式連接到通知中樞Connect your iOS app to Notification Hubs

  1. 在 Xcode 中建立新的 iOS 專案,並選取 [單一檢視應用程式] 範本。In Xcode, create a new iOS project and select the Single View Application template.

    Xcode - 單一檢視應用程式

  2. 設定新專案的選項時,請務必使用您在 Apple 開發人員入口網站上設定套件組合識別碼時使用的相同產品名稱組織識別碼When setting the options for your new project, make sure to use the same Product Name and Organization Identifier that you used when you set the bundle identifier in the Apple Developer portal.

    Xcode - 專案選項

  3. 在 [專案導覽器] 中,按一下您的專案名稱,再按一下 [一般] 索引標籤,然後尋找 [簽署] 。Under Project Navigator, click your project name, click the General tab, and find Signing. 請務必要選取適合您 Apple 開發人員帳戶的團隊。Make sure you select the appropriate Team for your Apple Developer account. XCode 應該會根據您的套件組合識別碼,自動提取您先前建立的佈建設定檔。XCode should automatically pull down the Provisioning Profile you created previously based on your bundle identifier.

    如果畫面未顯示您在 Xcode 中建立的新佈建設定檔,請嘗試重新整理簽署身分識別的設定檔。If you don't see the new provisioning profile that you created in Xcode, try refreshing the profiles for your signing identity. 按一下功能表列上的 Xcode ,再依序按一下 [喜好設定] 、[帳戶] 索引標籤、[檢視詳細資料] 按鈕、您的簽署身分識別,然後按一下右下角的 [重新整理] 按鈕。Click Xcode on the menu bar, click Preferences, click the Account tab, click the View Details button, click your signing identity, and then click the refresh button in the bottom-right corner.

    Xcode - 佈建設定檔

  4. 選取 [功能] 索引標籤,並務必要啟用推播通知Select the Capabilities tab and make sure to enable Push Notifications

    Xcode - 推播功能

  5. 新增 Azure 通知中樞 SDK 模組。Add the Azure Notification Hubs SDK modules.

    您也可以使用 Cocoapods,或手動將二進位檔新增至您的專案,來將 Azure 通知中樞 SDK 整合至應用程式中。You can integrate the Azure Notification Hubs SDK in your app by using Cocoapods or by manually adding the binaries to your project.

    • 透過 Cocoapods 整合Integration via Cocoapods

      將下列相依性新增至 podfile,以在您的應用程式中包含 Azure 通知中樞 SDK。Add the following dependencies to your podfile to include Azure Notification Hubs SDK into your app.

      pod 'AzureNotificationHubs-iOS'
      

      執行 pod install 來安裝新定義的 Pod,並開啟您的 .xcworkspaceRun pod install to install your newly defined pod and open your .xcworkspace.

      注意

      如果您在執行 pod install 時看到類似 [!] Unable to find a specification for `AzureNotificationHubs-iOS` 的錯誤,請執行 pod repo update 以從 Cocoapods 存放庫取得最新的 Pod,然後執行 pod installIf you see an error like [!] Unable to find a specification for `AzureNotificationHubs-iOS` while running pod install, please run pod repo update to get the latest pods from the Cocoapods repository and then run pod install.

    • 透過 Carthage 整合Integration via Carthage

      將下列相依性新增至 Cartfile,以在您的應用程式中包含 Azure 通知中樞 SDK。Add the following dependencies to your Cartfile to include Azure Notification Hubs SDK into your app.

      github "Azure/azure-notificationhubs-ios"
      

      接下來,更新及建置相依性:Next, update, and build dependencies:

      $ carthage update
      

      如需有關使用 Carthage 的詳細資訊,請參閱 Carthage GitHub 存放庫For more information about using Carthage, see the Carthage GitHub repository.

    • 透過將二進位檔複製到您的專案來進行整合Integration by copying the binaries into your project

      1. 下載以 zip 檔案形式提供的 Azure 通知中樞 SDK 架構,然後將其解壓縮。Download the Azure Notification Hubs SDK framework provided as a zip file and unzip it.

      2. 在 Xcode 中,以滑鼠右鍵按一下您的專案,然後按一下 [新增檔案至] 選項,將 WindowsAzureMessaging.framework 資料夾新增至 Xcode 專案。In Xcode, right-click your project and click the Add Files to option to add the WindowsAzureMessaging.framework folder to your Xcode project. 選取 [選項] ,並務必要選取 [必要時複製項目] ,然後按一下 [新增] 。Select Options and make sure Copy items if needed is selected, and then click Add.

        解壓縮 Azure SDK

  6. 將新的標頭檔新增至名為 HubInfo.h的專案。Add a new header file to your project named HubInfo.h. 此檔案會保存通知中樞的常數。This file holds the constants for your notification hub. 新增下列定義,然後以您的「中樞名稱」 以及先前記下的「DefaultListenSharedAccessSignature」 取代字串常值預留位置。Add the following definitions and replace the string literal placeholders with your hub name and the DefaultListenSharedAccessSignature noted earlier.

    #ifndef HubInfo_h
    #define HubInfo_h
    
        #define HUBNAME @"<Enter the name of your hub>"
        #define HUBLISTENACCESS @"<Enter your DefaultListenSharedAccess connection string"
    
    #endif /* HubInfo_h */
    
  7. 開啟 AppDelegate.h 檔案並新增下列 import 指示詞:Open your AppDelegate.h file add the following import directives:

    #import <WindowsAzureMessaging/WindowsAzureMessaging.h>
    #import <UserNotifications/UserNotifications.h>
    #import "HubInfo.h"
    
  8. 根據您的 iOS 版本,在 AppDelegate.m 檔案的 didFinishLaunchingWithOptions 方法中新增下列程式碼。In your AppDelegate.m file, add the following code in the didFinishLaunchingWithOptions method based on your version of iOS. 此程式碼會向 APN 註冊裝置控制代碼:This code registers your device handle with APNs:

    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound |
        UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];
    
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
    
  9. 在相同檔案中新增下列方法:In the same file, add the following methods:

        - (void) application:(UIApplication *) application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *) deviceToken {
        SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:HUBLISTENACCESS
                                    notificationHubPath:HUBNAME];
    
        [hub registerNativeWithDeviceToken:deviceToken tags:nil completion:^(NSError* error) {
            if (error != nil) {
                NSLog(@"Error registering for notifications: %@", error);
            }
            else {
                [self MessageBox:@"Registration Status" message:@"Registered"];
            }
        }];
        }
    
    -(void)MessageBox:(NSString *) title message:(NSString *)messageText
    {
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:messageText preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
        [alert addAction:okAction];
        [[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alert animated:YES completion:nil];
    }
    

    此程式碼會使用您在 HubInfo.h 中指定的連接資訊連接到通知中心。This code connects to the notification hub using the connection information you specified in HubInfo.h. 然後,它可提供裝置權杖給通知中樞,讓通知中樞能夠傳送通知。It then gives the device token to the notification hub so that the notification hub can send notifications.

  10. 如果應用程式在作用中時收到通知,您可以在相同檔案中新增下列方法以顯示 UIAlertIn the same file, add the following method to display a UIAlert if the notification is received while the app is active:

    - (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo {
        NSLog(@"%@", userInfo);
        [self MessageBox:@"Notification" message:[[userInfo objectForKey:@"aps"] valueForKey:@"alert"]];
    }
    
  11. 為了確認應用程式能夠順利運作,在裝置上建置並執行應用程式。To verify there are no failures, build and run the app on your device.

傳送測試推播通知Send test push notifications

您可以在 Azure 入口網站 中,使用 [測試傳送] 選項測試應用程式能否接收通知。You can test receiving notifications in your app with the Test Send option in the Azure portal. 它會將測試推播通知傳送至您的裝置。It sends a test push notification to your device.

Azure 入口網站 - 測試傳送

推播通知通常會以後端服務傳送,例如 Mobile Apps 或使用相容程式庫的 ASP.NET。Push notifications are normally sent in a back-end service like Mobile Apps or ASP.NET using a compatible library. 如果您的後端無法使用程式庫,您也可以直接使用 REST API 來傳送通知訊息。If a library isn't available for your back end, you can also use the REST API directly to send notification messages.

以下是可供您在傳送通知時檢閱的其他教學課程清單:Here is a list of some other tutorials you might want to review for sending notifications:

確認您的應用程式可接收推播通知Verify that your app receives push notifications

若要在 iOS 上測試推播通知,您必須將應用程式部署至實體 iOS 裝置。To test push notifications on iOS, you must deploy the app to a physical iOS device. 您無法利用 iOS 模擬器傳送 Apple 推播通知。You cannot send Apple push notifications by using the iOS Simulator.

  1. 執行應用程式並確認註冊成功,然後按下 [確定] 。Run the app and verify that registration succeeds, and then press OK.

    iOS 應用程式推播通知註冊測試

  2. 接下來,您應依照上一節的說明,從 Azure 入口網站傳送測試推播通知。Next you send a test push notification from the Azure portal, as described in the previous section.

  3. 推播通知會從特定通知中樞傳送至所有已註冊要接收通知的所有裝置。The push notification is sent to all devices that are registered to receive the notifications from the particular Notification Hub.

    iOS 應用程式推播通知接收測試

後續步驟Next steps

在此簡單範例中,您會將推播通知廣播到您已註冊的所有 iOS 裝置。In this simple example, you broadcasted push notifications to all your registered iOS devices. 若要了解如何將通知推送至特定 iOS 裝置,請繼續進行下列教學課程:To learn how to push notifications to specific iOS devices, advance to the following tutorial: