Skip to Content

Send Push Notifications To Your Native iOS App

Use SAP Mobile Services and an Apple Developer Account to send push notifications to you iOS app.
You will learn
  • How to configure push notifications on SAP Mobile Services
  • How to send a push notification from SAP Mobile Services to you native iOS application
sandeep-tdsSandeep T D SJune 6, 2024
Created by
sandeep-tds
March 23, 2023
Contributors
sandeep-tds
DanielGombar
  • Step 1
    Washing Machine

    You have built a native iOS application for a service technicians of a company that manufactures washing machines.

    As a technician you are assigned an area to serve. To plan your work, you need to constantly be aware of the open issues in your region.

    Therefore, you want to be notified immediately every time a new issue is created by the customer, even if you are not actively using the service technician app.

    In this tutorial, you will learn how to send push notifications to your mobile application using Apple Push Notification Service (APNS). Click here to learn more about push capabilities on SAP BTP SDK iOS.

  • Step 2
    1. Click Mobile Applications → Native/MDK in the sidebar.

    2. Click New located at the top right corner.

    3. Use the following table to fill the details requested in the New Application Wizard.

      Key Value
      IDsdk.ios.push.app
      NamePush Notification iOS App
      DescriptionPush Notification iOS App
      VendorNo Change
      License TypeNo Change
      Domain of Application RouteNo Change
    4. Click Next.

    5. Click Next on the XSUAA Settings step of the Wizard without making any changes.

    6. Select Native Application in the Assign Features for drop down menu.

    7. Enable Mobile Sample OData ESPM by selecting the check box in the features table.

    8. Click Finish.

    Server Side App Creation
  • Step 3
    1. Launch SAP BTP SDK Assistant for iOS.

    2. Click Create New located near the bottom left corner.

    3. Click Reuse Existing Application in the project template step.

    4. Select the SAP Mobile Services account in which you created the server side configuration and click Next.

      If prompted, use your SAP BTP credentials to complete the SSO login.

    5. Select the app you created in the second step and click Next.

      If prompted, use your SAP BTP credentials to complete the SSO login.

    6. Use the following table to fill the project details requested in the Provide the Xcode project configuration step of the assistant, and click Next.

      Key Value
      Product NameiOSPushApp
      Organisation NameSAP
      Organisation Identifiercom.sap
      Bundle IdentifierAuto generated
      PathNo Change
      Mac CatalystDeselect
    7. Click Next.

    8. Click Finish.

      If prompted, click Trust and Open in the warning pop-up to open the newly created Xcode project.

    Server Side App Creation
  • Step 4
    1. Click the iOSPushApp .xcodeproj file to open the project configuration of your app.

    2. Select Signing & Capabilities Tab.

    3. Enable Automatic manage signing.

    4. Select the correct Signing Certificate & Team.

    Signing Certificate
  • Step 5

    In order to use the Apple Push Notification service, we need to create a CSR file.

    1. On your Mac, open the Keychain Access application.

    2. Select Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority…

    3. Click Continue on the Introduction screen of the Certificate Assistant.

    4. Use the following table to fill the details requested in the Certificate Assistant.

      Key Value
      User Email Address<Your Apple Developer Email ID>
      Common NameTutorialPushCertificate
      CA Email AddressNo Change
      Request isSave to disk
      Let me specify key pair informationNo Change
    5. Click Continue.

    6. Select a location to save the certificate and Click Save.

    7. Click Done on the Conclusion screen.

    Server Side App Creation
  • Step 6
    1. Log into you Apple Developer Account.

    2. Click Certificates located under the Certificates, IDs & Profiles section.

    3. Click located next to the Certificates heading to add a new certificate.

    4. Select Apple Push Notification service SSL (Sandbox).

      If you are building a productive app, please select Apple Push Notification service SSL (Sandbox & Production).

    5. Click Continue.

    6. Select the App ID (**com.sap.iOSPushApp**) that matches the bundle identifier in your Xcode project.

      If you can’t find the App ID, either confirm the team and certificate configuration is accurate in the Xcode project or create a new identifier and update the bundle identifier in your Xcode project.

    7. Click Continue.

    8. Click Choose File and upload the TutorialPushCertificate certificate signing request file created in the previous step.

    9. Click Continue.

    10. Click Download to download your .cer

      The downloaded .cer file is issued by the Apple Worldwide Developer Relations Certification Authority.

    Certificate File on Apple Developer
  • Step 7
    1. On your mac, locate the downloaded .CER file.

    2. Open the .CER file to install the certificate.

      In case the Add Certificate dialog pops up make sure to choose Login from the dropdown and click on Add.

    3. Right click on the newly added certificate and click Get Info.

    4. Change the trust setting to Always Trust for the While using this certificate option.

    5. Right click on the certificate and click Export "Apple Sandbox Push Services: com.sap.iOSPushApp.

    6. Enter a file name TutorialPushCertificate and click Save to export the file.

    7. Add a password and click OK.

      You must provide this password to configure the certificate on SAP Mobile Services.

    P12 Certificate

    What file does SAP Mobile Services need to configure the APNS Endpoint?
    Select the correct one.

  • Step 8
    1. Go to you SAP Mobile Services admin cockpit.

    2. Click Mobile Applications → Native/MDK in the sidebar.

    3. Click sdk.ios.push.app.

    4. Click Mobile Push Notification under Assigned Features section.

    5. Select Sandbox for the APNS Endpoint: dropdown under Apple section.

    > This tutorial covers the certificate based approach.

    1. Click Browse and upload the TutorialPushCertificate.p12 file.

    > A .p12 file is a encrypted container for the certificate and private key. This file is needed by Mobile Services for the APNS configuration.

    1. Enter the configured password.

    2. Click Save.

    Adding Certificate to SAP Mobile Services

    Which types of APNS authentication are supported by SAP Mobile Services?

  • Step 9
    1. Click (Start the active scheme) in Xcode to run the application.

    2. Complete the onboarding steps.

    > Please refer to the pre-requisite for a step by step guide for the onboarding flow.

    1. Go to you SAP Mobile Services admin cockpit.

    2. Click Mobile Applications → Native/MDK in the sidebar.

    3. Click sdk.ios.push.app.

    4. Click Mobile Push Notification under Assigned Features section.

    5. Click Push Registrations (x).

    6. Click Send Notification.

      If the number of registrations are more than one, click send notification for the device you can access.

    7. Enter a message and click Send.

    8. Tap the notification on your device to open the app.

      Try sending a notification when the app is in background and not running.

    Push Notifications

    If you have configured your Apple Watch to display push notifications received on your iPhone, the push notification you have sent via Mobile Services will also be displayed on your Apple Watch.

  • Step 10
    1. Go to you SAP Mobile Services admin cockpit.

    2. Click Mobile Applications → Native/MDK in the sidebar.

    3. Click sdk.ios.push.app.

    4. Click Mobile Push Notification under Assigned Features section.

    5. Click Push Registrations (x).

    6. Click Send Notification.

    7. Select Advanced tab, and use the following JSONpayloads.

      The advanced option allows app developers to define icons, sound, title, badge number etc. Please refer to the official documentation for further details.

      json
      Copy
      {
          "alert": "Notification With A Message",
          "badge": 0,
          "priority": "high",
          "sound": "DefaultNotificationSound"
      }
      
      json
      Copy
      {
          "badge": 100,
          "priority": "high",
          "sound": "DefaultNotificationSound"
      }
      
      json
      Copy
      {
          "alert": "Notification With Only A Message",
          "priority": "high",
          "sound": "DefaultNotificationSound"
      }
      
      Advanced Push Notifications

    Congratulations on successfully completing the tutorial. You can now send push notifications to your native applications built using SAP BTP SDK for iOS.

Back to top