Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
AlexGiguere
Contributor

You wonder how to send push notifications from your SAP Business Suite system directly to your mobile devices.


Prerequistes:


Development access to a NetWeaver / Business Suites system


ABAP Git installed on your backend system


SAP Cloud Connector configured with principal propagation


An SCP sub-account with mobile services activated (Neo or Cloud Foundry)


A native app configured in mobile services with the push notification feature enabled


 

The goal is to be able to sent push notifications from your backend in ABAP directly to your mobile devices (iOS, Android).


Configuration Steps:


Step 1 - Create and configure an RFC destination


Step 2 - Import SCP certificate to the SAP System Trust Store


Step 3 - Test your connection


Step 4 - Install abapGit


Step 5 - Import the SCPmsPushNotificationREST_API repo in your system


Step 6 - Configure mobile services


Step 7 - Use the API to send push notifications


Step 8 - Configure your other systems


 

You can find the detail of all these steps on my GitHub repo that you will need to clone via abapGit


 

Activate the push notification capability of your iOS application in Xcode. You app should be configured with the SCP iOS SDK.


 

Launch / onboard your app and verify the device token has been uploaded successfully to CPms under user registration, check for the field APNS device token.


 

Create an ABAP program with your business logic for dispatching push notification to your devices, here is an example of how to used the API.


 
    DATA(notification) = zcl_scpms_notification=>create_apns_notification( ).

notification->set_title( alert_title ).

notification->set_body( alert_body ).

notification->set_badge( badge_value ).

DATA scp_users TYPE zscpms_user_t.

TRY.
DATA(push) = zcl_scpms_push_notification=>get_instance( ).

APPEND INITIAL LINE TO scp_users ASSIGNING FIELD-SYMBOL(<scp_user>).
<scp_user>-name = 'myUserID'.

DATA(response) = push->push_to_app_users(
application_id = application_id
users = scp_users
notification = notification ).

response->get_status(
IMPORTING
code = DATA(code)
reason = DATA(reason) ).

IF code BETWEEN 200 AND 299.
"Success
ELSE.
"Handle network error
ENDIF.

CATCH zcx_scpms_push_notification INTO DATA(ex).
"Handle exception error
ENDTRY.

 

for enhancements or bugs, please send me pull requests

 

happy coding


 

Alex
5 Comments
alsp80
Participant
0 Kudos
Hi Alex,

first of all thanks for implementing this class and making it available via GitHub. I've started using it and have to say that it really is super easy to use it.

I have one question: you offer as well the content-available property. Can you share an example of how to use the classes to trigger a silent background push message? Is it enough to only set the content-available field to X, provide users and app id and don't provide any other fields, e.g. title or body? Do you have any experience on this?

Thanks,
Alex
AlexGiguere
Contributor
0 Kudos
Hi Alex, glad to ear that,

as for your background push question, yes it is a simple as setting the content available to X

you should not supply any other fields (title, body) or they will be ignored

add the device capability named background mode and check push notification

also there are some different delegate API to hook up in your app delegate

thanks
alsp80
Participant
0 Kudos
Hi Alex,

thanks for coming back and provide an answer. Indeed, I figured out as well that I should only send an X in content available and keep initial all other fields.

Checking in my app I could consume the silent push only if the app was in foreground. When my app was in background it seemed that nothing happened, I assume that I have to use some specific API offered by the SDK that would allow a more expansive operation (network requests to sync the offline store) as otherwise iOS will not allow me to do this.

Would appreciate if you would have any details or could point me to an example on how to do it. Obviously would be very nice to have such an example in your GitHub repo. I will definitly contribute to this repo if there is any additional thing that I have and that might help others, thanks again for sharing your code.

Thanks,
Alex
AlexGiguere
Contributor
0 Kudos

from a server side perspective, there is nothing else to do

if you want to support background notification, you need to add the device capabilities in Xcode for background modes and check notification …

take in mind that if you force kill your app (close it with the app switcher), iOS will not wake your app when a background notification is sent … background notification works best when you app is minimized …

also if you are running you app from Xcode then make sure you are using the APNS development in Mobile Services, check the log in MobileServices and you will know if scpms was able to forward the notification successfully to APNS

if my memory is good, you have something like 30-45 sec to send a request to refresh your data

add this method to your app delegate

application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

you can find good articles/blogs on RayWenderlich

hope that help

alex

 

 

 

alsp80
Participant
0 Kudos

Hi alexandre.giguere3,

I saw you accepted the Pull Request today. 🙂
I have to admit that I made these changes somewhere last year but forgot sending the PR back then. Happy to see that you're still maintaining the repo.

I had one question in this regard: we're looking into migrating our stuff from Neo to CF. I assume the structure of the message to CPms for push messages doesn't change because of that however I was wondering whether you're aware of any other topics that one would need to consider, e.g. using another kind of user instead of S-User. Are you aware of any resource and did you implement such a scenario of sending push messages from an ABAP backend to CPms running on CF instead of Neo?

Thanks,
Alex

Labels in this area