Skip to Content

Enable Push Notifications in the MDK Public Store Client

Use the SAP Mobile Services to enable push notifications in the MDK public store client.
You will learn
  • How to use MDK push register action
  • How to use predefined push configuration for the public store version of SAP Mobile Services client (MDK client)
  • How to send push notification to an MDK app
jitendrakansalJitendra KansalNovember 24, 2022
Created by
jitendrakansal
October 4, 2022
Contributors
jitendrakansal
maximilianone

Prerequisites

You may clone an existing metadata project from GitHub repository and start directly with step 4 in this tutorial.

MDK
  • Step 1
    1. Open the SAP Mobile Services cockpit, click Mobile Push Notification feature.

      MDK

      You can add Mobile Push Notification feature by clicking on + icon in case feature is not already assigned to the application.

    2. Select SAP Mobile Services Client under Predefined for option, click Save.

      MDK

      Predefined push is supported only for the MDK (SAP Mobile Services client) public store client.

      If you want to enable push notification in your custom MDK client then follow this tutorial.

    Which option is not available under Predefined for dropdown?

  • Step 2
    1. Launch the Dev space in SAP Business Application Studio.

    2. Click Start from template on Get Started page.

      MDK

      If you do not see the Get Started page, you can access it by typing >get started in the center search bar.

      MDK
    3. Select MDK Project and click Start.

      MDK

      If you do not see the MDK Project option check if your Dev Space has finished loading or reload the page in your browser and try again.

      This screen will only show up when your CF login session has expired. Enter your login credentials, click Sign in. After successful signed in to Cloud Foundry, select your Cloud Foundry Organization and Space where you have set up the initial configuration for your MDK app and click Apply.

      MDK

    4. In Basic Information step, provide the below information and click Finish:

      Field Value
      MDK Template TypeSelect Empty from the dropdown
      Your Project Name Provide a name of your choice. MDK_Push is used for this tutorial
      Your Application Name <default name is same as project name, you can provide any name of your choice>
      Target MDK Client Version Leave the default selection as MDK 6.0+ (For use with MDK 6.0 or later clients)
      Choose a target folder By default, the target folder uses project root path. However, you can choose a different folder path
      MDK

      More details on MDK template is available in help documentation.

    5. After clicking Finish, the wizard will generate your MDK Application based on your selections. You should now see the MDK_Push project in the project explorer.

  • Step 3

    In this step, you will create the following actions:

    • Push Notification Register action: this will register the device with SAP Mobile Services for push notification.

    • Message actions: these will display a message if Push Notification Register action has succeeded or failed.

    1. Create a Push Notification Register action.

      Right-click the Actions folder | MDK: New Action | choose MDK Other Actions in Category | click Push Notification Register Action | Next.

      MDK

      Provide the below information:

      Property Value
      Action NamePushRegister
      MDK

      More details on Push Notification Action is available in help documentation.

      Click Next and then Finish on the confirmation step.

    2. Define a success message if the Push Register Notification action is succeeded.

      Right-click the Actions folder | MDK: New Action | choose MDK Message Actions in Category | click Message Action | Next.

      MDK

      Provide the below information:

      Property Value
      Action NamePushRegisterSuccessMessage
      Type Select Message from the dropdown
      Message Push Notification registered
      Title Success
      OKCaption OK
      OnOK --None--
      CancelCaption leave it blank
      OnCancel --None--
      MDK

      Click Next and then Finish on the confirmation step.

    3. Define a failure message if the Push Register Notification action is failed.

      Right-click the Actions folder | MDK: New Action | choose MDK Message Actions in Category | click Message Action | Next.

      MDK

      Provide the below information:

      Property Value
      Action NamePushRegisterFailureMessage
      Type Select Message from the dropdown
      Message Push Notification didn't register
      Title Failure
      OKCaption OK
      OnOK --None--
      CancelCaption leave it blank
      OnCancel --None--
      MDK

      Click Next and then Finish on the confirmation step.

    4. Define Success and Failure actions for PushRegister.action.

      In the action editor for the new action, expand the Common Action Properties and provide the below information:

      Property Value
      Success Action Click the link icon to bind it to PushRegisterSuccessMessage.action
      Failure Action Click the link icon to bind it to PushRegisterFailureMessage.action

      When PushRegister.action gets executed successfully then PushRegisterSuccessMessage.action will be triggered or if PushRegister.action fails then PushRegisterFailureMessage.action will be triggered.

      MDK
  • Step 4

    In the step, you will set and call the Push Register Notification action when app is updated with the new metadata.

    It is up to developers how they want to call a Push Register Notification action.

    In Application.app file, bind the OnDidUpdate event to PushRegister.action.

    MDK
  • Step 5

    So far, you have learned how to build an MDK application in the SAP Business Application Studio editor. Now, you will deploy the application definitions to Mobile Services to use in the Mobile client.

    1. Right-click Application.app and select MDK: Deploy.

      MDK
    2. Select deploy target as Mobile Services.

      MDK
    3. Select Mobile Services Landscape.

      MDK
    4. Select the application from Mobile Services.

      MDK
    5. If you want to enable source for debugging the deployed bundle, then choose Yes.

      MDK

      You should see Deploy to Mobile Services successfully! message.

      MDK
  • Step 6

    SAP Business Application Studio has a feature to display the QR code for onboarding in the Mobile client.

    Click the Application.app to open it in MDK Application Editor and then click the Application QR Code icon.

    MDK

    The On-boarding QR code is now displayed.

    MDK

    Leave the Onboarding dialog box open for the next step.

  • Step 7

    Make sure you are choosing the right device platform tab above. Once you have scanned and on-boarded using the onboarding URL, it will be remembered. When you Log out and on-board again, you will be asked either to continue to use current application or to scan new QR code.

    Once you have scanned and on-boarded using the onboarding URL, it will be remembered. When you Log out and on-board again, you will be asked either to continue to use current application or to scan new QR code.


    What Message would be displayed in case Push register action fails?

Back to top