Working with user notifications in mobile applications



Overview

When a user works with an application, regularly you may need to notify the user about a particular event. The event can occur based on a schedule or in response to another event.

In the mobile application system, the event can occur on the mobile device the user handles as well as in another place of the system.

To notify users about the occurrence of an event in the system, you can rely on user notifications. You can create them locally on your users' mobile devices or send them to the devices via push services.

Typically, local notifications inform users about events that happen on users' mobile devices.

By using push notifications, the system can inform users that there has been a change in the system's data that is important for the users. As a rule, there is a dedicated node of the information system that is responsible for sending push notifications to users.

Also, there are external services that can inform your mobile application users on currency exchange rates, results of sports events, weather forecasts, and so on.

Local notifications

Local notifications serve for informing a mobile device's user about events that happen directly on the device. These notifications can be instant or scheduled.

They inform users about events of different kinds and their behavior on users' mobile devices can be different as well.

You use instant notifications when you need to inform a user immediately about an event, say, completion of a particular process. For instance, the process of data synchronization with an external system.

Scheduled notifications let you remind a user to perform this or that operation at the specified time.

Scheduled notifications can be non-recurring and recurring.

For instance, you can use a non-recurring scheduled notification to remind the user to make a phone call to a particular customer at the specified time as it is recorded in the system.

On the contrary, you can use a recurring scheduled notification when an operation should be repeated, say, daily, no matter what external events are.

To be able to use local notifications, enable the Local notifications permission in your mobile configuration. This makes the mobile application builder add the corresponding permission for the mobile application under construction.

Note that developer's 1C:Enterprise mobile platform has all required permissions for working with local notifications. So, once you finished developing your notification system in the configuration, you should check whether it works on user's 1C:Enterprise mobile platform. To do this, use the builder and verify how the resulting application works on the target mobile device.

To work with local notifications, use the deliverable notification manager (the DeliverableNotifications global context property) and the DeliverableNotification object. The object describes the notification itself, including parameters that affect its representation on screen. The manager lets you control the notification engine.

Let us take a closer look at the process of creating local notifications.

&OnClient
Function CreateNotification(Title, Text, Data = 0, FireDate, RepeatInterval = 0)
  Notification = New DeliverableNotification;
  Notification.Title = Title;
  Notification.Text = Text;
  Notification.Data = Data;
  Notification.FireDateUniversalTime = FireDate;
  Notification.RepeatInterval = RepeatInterval;
  Notification.SoundAlert = SoundAlert.Default;
  Return Notification;
EndFunction

&OnClient
Procedure SpecifyNotification(Command)
  Notification = CreateNotification(NStr("en='Title'"), NStr("en='Text'"), 2018, '00010101');
  DeliverableNotifications.AddLocalNotification(Notification);
EndProcedure

When creating a notification, pay attention to the following peculiarities:

  • The date and time the notification is to display for the first time is specified in a universal time format (UTC). To convert the local date and time to UTC, you can use the ToUniversalTime() global context function.

  • If the FireDateUniversalTime property is set to an empty value or the property is not specified, the notification is to display immediately. Such a notification lets you notify a user that the application has finished a long-lasting operation, for instance, data synchronization.

  • If you need to display the notification regularly, use the RepeatInterval property of the DeliverableNotification object. This lets you implement the behavior of an unconditional timer that displays the notification after the specified time period. The value you set for the property is interpreted in accordance with the target mobile operating system's specifics. For more information, refer to Syntax Assistant. You cannot specify the end date and time of the period when the notification should be fired. On Windows, the notification is to display five times, including the first occurrence.

  • If it is necessary, you can specify a badge. This is a numerical value displayed in the notification shade (on Android) or on the top of the application's icon (on iOS). For this purpose, use the Badge property. On iOS, you can set and get the badge value by using the SetBadge() and GetBadge() methods of the deliverable notification manager. On Windows, the capability of changing the badge of the application's menu is not supported.

  • When displaying the notification on the target mobile device, you can play a particular melody on the device. To specify the melody to play, use the SoundAlert property of the DeliverableNotification object. If you set this property to the SoundAlert.Default system enumeration value, the system displays the default melody specified in the target mobile operating system. If you set a file's name as the value of the SoundAlert property, the mobile operating system plays this file. However, on the developer's 1C:Enterprise the mobile platform, you cannot specify resources, including media files. To attach the given file to the resulting mobile application, use the capabilities of the mobile application builder. As a result, you can test playing sound notifications from media files in the user's mobile application only.

Sometimes you may need to delete the specified notifications that have not been fired yet. This can be necessary when the event the notification informs about is already performed.

To delete local notifications, you can use the CancelLocalNotifications() method of the deliverable notification manager. Note that the method deletes all the local notifications that were established with the given mobile application and whose fire date and time is not passed yet.

Once a notification is displayed on the mobile device screen, tapping it results in the application launch or activation. However, this may be not enough for handling the notification completely. In this case, you can use the notification handler. To connect this handler, use the AttachNotificationHandler() method of the deliverable notification manager.

&OnClient
Procedure OnOpen(Refusal)
  Handler = New NotifyDescription(NStr("en='NotificationHandler'"), ThisObject);
  DeliverableNotifications.AttachNotificationHandler(Handler);
EndProcedure

&OnClient
Procedure NotificationHandler(Notification, Local, Displayed, ExtraParameters) Export
  // Required actions
EndProcedure

As a result of running this code, after the mobile application user taps the notification, the mobile application that created the notification gets activated and the application calls the notification handler. In the hander, you can implement how you want to handle the notification. Note that the object passed as the method's Notification parameter includes information on the actual notification in the Text and Data properties only. The other properties are populated with default values.

Also, note that the notification can be either displayed or not displayed in the notification shade. To notify the mobile application about the fact of whether the notification was displayed there or not, use the Displayed parameter. For instance, if the mobile application is running and active, the system does not display the local notification, though it calls the notification handler whose Displayed parameter is set to True. In this instance, catching the user's attention is the application developer's task.

Push notifications

Push notifications are aimed at notifying mobile application users about events that happen somewhere else in the system, rather than in the mobile application itself. For instance, in the corporate information system, there has been a change of data that is important for mobile application users.

In this section, the terms notification and push notification are interchangeable.

When working with push notifications, the following separate systems are used:

  • The mobile application. It receives notifications and implements a mobile device's reaction to them.

  • The application that sends notifications (sender). You use an application based upon 1C:Enterprise platform as a sender.

  • The notification delivery service. It provides notification transfer from the sender to the recipient (mobile application). This can be either of the following services:

           o   Apple Push Notification Service (APNs, https://developer.apple.com/library/content/documentation/NetworkingInternet/
Conceptual/RemoteNotificationsPG/APNSOverview.html
)

           o   Google Cloud Messaging (GCM, http://developer.android.com/intl/ru/google/gcm/index.html)

           o   Firebase Cloud Messaging (FCMhttps://firebase.google.com/docs/cloud-messaging/)

           o   Windows Push Notification Services (WNS, https://docs.microsoft.com/windows/uwp/controls-and-patterns/tiles-and-notifications-windows-push-notification-services--wns--overview)

  • 1C Company's proxy service for notification delivery (https://pushnotifications.1c.com). This service is intended for assisting in delivering notifications from out-of-the-box applications based on 1C:Enterprise platform. The service can interact with all the notification delivery services that 1C:Enterprise mobile platform supports. The service relies on these services, which means it uses them implicitly.

The service lets you separate recipients of one sender from other senders that work with the same mobile application.

Typically, the security policy of a notification delivery service prohibits publishing confidential information. To follow the policy, 1C Company's service lets you avoid publishing this information. Peculiarities of working with the service are described below.

In general, sending a notification includes the following steps:

  • The sender creates the notification.

  • The sender defines the recipient list for the notification.

  • The sender connects to the notification delivery service.

  • The sender transfers the notification and the recipient list to the service.

  • The services deliver notifications to the specified mobile applications.

  • The mobile application on each target mobile application handles the notification.

Note that the notification delivery service does not guarantee to deliver a notification to the target mobile device.

To be able to use notifications, enable the Push notifications permission in your mobile configuration. This makes the mobile application builder add the corresponding permission for the mobile application under construction.

Work with developer's 1C:Enterprise mobile platform has certain peculiarities we will describe below.

Anyway, once you finished developing your notification system in the configuration, you should check whether it works on the user's 1C:Enterprise mobile platform. To do this, use the builder and verify how the resulting application works on the target mobile device with all notification delivery services engaged.

Handling a push notification slightly differs from handling a local notification (for more information, refer to Local notifications). Obviously, the Local parameter has the False value if the hander is passed for push notification.

Algorithm of working with notification delivery services

To understand how to work with push notifications, take into account that there are a few roles that take part in the process of developing and implementing the system. In certain cases, an actor can play several roles, anyway, the number of roles remains the same. The roles are as follows:

  • Mobile application developer - develops the mobile application that receives notifications; implements all the functionality that is required for receiving notifications.

  • Notification sender developer - develops the information system that sends notifications as well as the engine that receives and stores notification recipients' IDs.

  • Mobile application user - uses and configures the mobile application, that is why the configuration settings should be simple and clear even for inexperienced users.

  • Notification sender implementation engineer - sets up and configures the system that sends notifications in the information system user's network.

When considering algorithms of working with this or that service, we will describe actions on behalf of an actor having this or that role.

Except for the actions described in the section below, implementation of the following steps is required, and we are not going to mention these steps again:

  • Implementing a mobile application's reaction to a notification - mobile application developer's task

  • Implementing sending a notification - notification sender developer's task

Also, we suppose that both the mobile application and notification sender "know" they can interact:

  • The sender has a public API (exchange service) used for receiving notification recipient's ID from the mobile application

  • The recipient (mobile application) can use the exchange service for performing both actions mentioned above

APNs

The mobile application developer should do the following:

  • Get a special certificate for the mobile application on Apple's dedicated site. The certificate gives the mobile application the ability to receive notifications.

  • Provide the certificate to the notification sender.

  • Implement receiving notification recipient's ID and delivering the resulting object to the notification sender.

Notification sender developer should do the following:

  • Implement the mechanism of receiving and storing notification recipients' IDs.

Notification sender implementation engineer should do the following:

  • From the mobile application developer, get the certificate of the mobile application that will receive notifications.

  • Upload the certificate to the notification sender system.

Mobile application user should do the following:

  • For the mobile application, specify the parameters of the exchange service the notification sender provides.

  • Initiate creating the ID for the notification recipient and sending the ID to the notification sender.

GCM

Mobile application developer should do the following:

  • Implement entering and storing GCM project numbers of the notification sender instances whose notifications the mobile application can receive.

  • Implement receiving notification recipient's ID and delivering the resulting object to the notification sender.

Notification sender developer should do the following:

  • Implement the engine for entering and storing the API key and the GCM project number for each notification sender instance.

  • Implement the engine for receiving and storing notification recipients' IDs.

Notification sender implementation engineer should do the following:

  • Register the particular notification sender instance on Google's dedicated site.

  • Specify the resulting API key and GCM project number in the corresponding settings of the notification sender instance.

Mobile application user should do the following:

  • For the mobile application, specify the parameters of the exchange service the notification sender provides.

  • Initiate receiving the GCM project number (saved in the sender's infobase), creating the ID of the notification recipient and sending the ID to the notification sender.

FCM

The mobile application developer should do the following:

  • Get a server key for the mobile application in the Firebase online service. This gives the mobile application the ability to receive push notifications.

  • Provide the server key to the notification sender.

  • Implement receiving notification recipient's ID and delivering the resulting object to the notification sender.

Notification sender developer should do the following:

  • Implement the engine for entering and storing the server key for each notification recipient.

  • Implement the engine for receiving and storing notification recipients' IDs.

Notification sender implementation engineer should do the following:

  • For the mobile application that will receive notifications, obtain the server key of the Firebase project from the mobile application developer.

  • Specify the server key in the corresponding settings of the notification sender instance.

Mobile application user should do the following:

  • For the mobile application, specify the parameters of the exchange service the notification sender provides.

  • Initiate creating the ID of the notification recipient and sending the ID to the notification sender.

WNS

The mobile application developer should do the following:

  • Get application secrets and an application security ID for the mobile application on Microsoft's dedicated site. They give the mobile application the ability to receive push notifications.

  • Provide the application secrets and the application security ID to the notification sender.

  • Implement receiving notification recipient's ID and delivering the resulting object to the notification sender.

Notification sender developer should do the following:

  • Implement the engine for entering and storing application secrets and application security IDs. This data is required for receiving an access token that is used for sending notifications.

  • Implement the engine for receiving, storing, and updating access tokens.

  • Implement the engine for receiving and storing notification recipients' IDs.

Notification sender implementation engineer should do the following:

  • From the mobile application developer, get the application secrets and the application security ID of the mobile application that will receive notifications.

  • For the notification sender, specify the application secrets and the application security ID.

Mobile application user should do the following:

  • For the mobile application, specify the parameters of the exchange service the notification sender provides.

  • Initiate creating the ID of the notification recipient and sending the ID to the notification sender.

1C Company's notification delivery service

To simplify the process of sending and receiving notifications in out-of-the-box solutions based on 1C:Enterprise platform, 1C Company developed a proxy notification delivery service.

The mobile application developer should do the following:

  • Choose which services to use for delivering notifications to the mobile device and then provide 1C Company's service with the artifacts that are needed for sending notifications via the selected services. Note that these artifacts might include confidential information.

  • Implement receiving notification recipient's ID and delivering the resulting object to the notification sender.

Notification sender developer should do the following:

  • Implement the engine for entering and storing the sender API key for the given notification sender instance. It is the notification sender implementation engineer who registers the particular notification sender instance on 1C Company's service site.

  • Implement the engine for receiving and storing notification recipients' IDs.

Notification sender implementation engineer should do the following:

  • Register the particular notification sender instance on 1C Company's service site. Specify the obtained sender API key to the corresponding settings of the notification sender.

Mobile application user:

  • For the mobile application, specify the parameters of the exchange service the notification sender provides.

  • Initiate creating the ID of the notification recipient and sending the ID to the notification sender.

Working with the APNs service

To practice sending notifications to iOS mobile devices, you should configure developer's 1C:Enterprise mobile platform. When building your mobile application, you should use a special provision profile, for which working with push notifications is enabled. Also, you should specify a new ID for your target mobile application. Note that you cannot use the com.e1c.mobile and com.e1c.mobile.ios IDs because they are reserved for 1C Company's purposes.

To be able to establish a connection to APNs, the sending computer must have the certificate of notification recipient's mobile application.

There are two kinds of certificates for APNs: Apple Development iOS Push Services (developer's certificate) and Apple Production iOS Push Services (public mobile application certificate).

Developer's certificate is intended for developing and debugging the mobile application. You should use this certificate if you install the application via development tools.

You should use the public mobile application certificate if you distribute your application via an application store.

There are the following requirements for a certificate aimed at the mobile platform:

  • The mobile application's certificate must be in a .PEM format.

  • The certificate must include the Bag Attributes section having the friendlyName attribute. By using the value of this attribute, 1C:Enterprise platform distinguishes the developer's certificate from a public mobile application's certificate. 1C:Enterprise platform rejects certificates without this attribute.

IMPORTANT! The description of the developer's console is valid at the document creation time.

To prepare sending notifications via APNs, the mobile application's developer should perform the following actions:

  1. Open developer's console (iOS Dev Center, https://developer.apple.com/devcenter/ios/index.action) on behalf of the user having administrator's rights in the console.

  2. To the right of console's web page, click Certificates, Identifiers & Profiles in the iOS Developer Program section.

  3. If the mobile application that will receive notifications already has an App ID, skip this step.

If the mobile application has no App ID, create it for the application as described below:

          1. In the iOS Apps section, click Identifiers.

          2. On the top of the iOS AppIDs list, click the + button.

This button is available only if the user has sufficient rights in the console.

          3. In the Name field, type the description for the application, in Latin letters.

          4. In the App ID Suffix section, select the Explicit App ID item.

          5. In the Bundle ID field, type mobile application's full ID.

You can learn this ID via the mobile application builder.

          6. In the App Services section, enable the Push Notifications item.

          7. Click Continue.

          8. Check the parameters you specified and click Submit.

          9. Click Done.

The App ID for your mobile application is created.

4. The next step is to create a provisioning profile for the mobile application that can receive notifications. Later, you can use the provisioning profile in the mobile application builder.

         1. In the Certificates, Identifiers & Profiles section, click the Provisioning profiles - All item.

         2. On the top of the iOS Provisioning Profiles list, click the + button.

         3. You choose the type of profile depending on its purpose. If you create the provisioning profile for developing and debugging the application, then in the Development section, select the iOS App Development item. If you create the provisioning profile for distributing the application, then in the Distribution section, select the App Store item. Further steps you see in the provision profile creation wizard depend on the provision profile type.

             1. If you selected the developer's provision profile and clicked Continue:

                  1. Select the App ID of the application for whose building you create the provisioning profile and then click Continue.

                  2. Select certificates of the developers that will be able to develop applications in Xcode by using this provisioning profile and then click Continue.

                  3. Select the devices where the application built with this provisioning profile will work and then click Continue.

                  4. Type the description for the provisioning profile (in Latin letters) and then click Generate.

             2. If you selected a provisioning profile for distribution and clicked Continue:

                  1. Select the App ID of the application for whose building you create the provisioning profile and then click Continue.

                  2. Select the certificate of the application's vendor and then click Continue.

                  3. Type the description for the provisioning profile (in Latin letters) and then click Generate.

             3. To download the resulting provision profile for further usage (in Xcode or in the mobile application builder), click Download.

5. To create a request for a mobile application certificate, create a certificate request file. For this purpose, you need a computer running on Mac OS X. When creating the request, keep the web browser with the developer's console displayed.

         1. Run the Keychain utility.

         2. In the utility, select the command Keychain Access - Certification assistant - Request a certificate from a certificate authority.

         3. In the resulting dialog, specify the fields. For the User E-mail field, it is recommended to specify the email address you used for registration in iOS  Developer Program. For the Request field, specify the Saved on disk value.

         4. Click Continue.

The Keychain utility generates a .certSigningRequest certificate request file.

6. To generate notification sender's certificate, return to the web browser with the developer's console displayed.

         1. In the Certificates, Identifiers & Profiles section, click the Certificates - All item.

         2. On the top of the iOS Certificates list, click the + button.

         3. If you need the certificate for developing and debugging the application, select Apple Push Notification service SSL (Sandbox). If you need the certificate for distributing the application, select Apple Push Notification service SSL (Production). Then click Continue.

         4. In the App ID field, specify App ID of your application and then click Continue.

         5. Click Continue again. At this step, you can create a certificate request file. You already created this file earlier, so you can skip this step now.

         6. Upload the .certSigningRequest certificate request file you created earlier and then click Generate.

         7. Once the certificate is generated, click Download to download the certificate file.

7. Convert the certificate to an appropriate format by using the computer running on Mac OS X where you generated the certificate request file.

         1. Run the Keychain utility.

         2. In the utility, upload the certificate file.

         3. In the utility, export the certificate to a file having .P12 format.

         4. To convert the resulting certificate from .P12 format to .PEM format, in the OS X console, run the following command:

openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts

You will need the resulting certificates:

  • Certificate in .P12 format - use it if you send notifications via 1C Company's notification delivery service. The mobile application developer uses this certificate to register the application as the notification recipient in 1C Company's notification delivery service.

  • Certificate in .PEM format - use it if you send notifications directly via the APNs service. Provide this certificate to the notification sender developer or to the notification sender implementation engineer (if the notification sender application has the capability of specifying the certificate of the notification recipient application).

Working with the GCM service

IMPORTANT! The description of the developer's console is valid at the document creation time.

When deploying and configuring the notification sender application in a customer's network, the implementation engineer of the application should perform the following actions:

1. Open developer's console (Google Developers Console, https://console.developers.google.com/project).

2. To create a project, click Create project.

3. To open the project's properties, on the IAM & admin menu, select Settings.

4. Write down the number displayed below the Project number field. This project number is required for the mobile device to generate the recipient ID.

5. To enable using the GCM service:

         1. Select your application.

         2. Click the APIs & Services menu.

         3. Click ENABLE APIS AND SERVICES.

         4. Locate and open the Google Cloud Messaging library.

         5. Click ENABLE.

6. To get the API key:

         1. On the APIs & Services menu, select Credentials.

         2. Click the Credentials tab.

         3. Click the Create credentials button and then click API key.

         4. Click RESTRICT KEY.

         5. In the Key restriction section, select IP addresses (web servers, cron jobs, etc.).

         6. In the Accept requests from these server IP addresses field, specify the IP address of the server that will work as the notification sender for your application, and then click Save.

For testing purposes, you can specify the 0.0.0.0/0 IP address. Later, when editing the API key's properties, you can change the list of IP addresses to accept notifications from.

The resulting API key is displayed in the API key field.

It is recommended to treat this value as confidential information because if a third party gets access to this key, it lets them send push notifications on behalf of you provided that you have not specified particular IP addresses for the API key.

7. Use the API key value as the authentication key for sending notifications (the AuthenticationData parameter of the Send() method of the DeliverableNotificationSendManager object).

8. Provide the API key value to the implementation engineer of the notification sender application. The engineer is to specify this value in the application's settings.

Working with the FCM service

IMPORTANT! The description of the developer's console is valid at the document creation time.

When deploying and configuring the notification sender application in a customer's network, the implementation engineer of the application should perform the following actions:

1. Open developer's console (Firebase Console, https://console.firebase.google.com).

2. To create a project, click Add project.

         1. In the Project name field, specify the name of your project. It can only contain Latin letters, digits, spaces, and these characters: -!'"

         2. In the Analytics location field, specify the country/region of your organization.

         3. In the Cloud Firestore location field, specify where your Cloud Firestore data resides.

         4. Click Create project and then click Continue.

3. To open the project's properties, on the menu, select Project settings, and then click the General tab.

4. Click Add Firebase to your Android app and then perform the following:

         1. In the Android package name field, specify the full ID of your Android application. Google will publish your application in the Google Play store with this ID. Also, you will use this ID for building the mobile application via the mobile application builder.

         2. Click Register app.

         3. Click Download google-services.json to download the resulting google-services.json file. This file is to be specified in the mobile application builder.

         4. Click Next.

         5. Click Next.

         6. Click Continue to console.

5. Click the Cloud Messaging tab.

6. Write down the value displayed in the Server key field.

It is recommended to treat this value as confidential information because if a third party gets access to this value, it lets them send push notifications on behalf of you.

7. Use the Server key value as the authentication key for sending notifications (the AuthenticationData parameter of the Send() method of the DeliverableNotificationSendManager object).

8. Provide the Server key value to the implementation engineer of the notification sender application. The engineer is to specify this value in the application's settings.

Migrating from GCM to FCM

To migrate from using the GCM service to FCM service for sending push notifications, the implementation engineer of the application should perform the following actions when deploying and configuring the notification sender application in a customer's network:

1. Open developer's console (Firebase Console, https://console.firebase.google.com).

2. To create a project, click Add project.

         1. From the Project name drop-down list box, select the GCM application to migrate to the FCM service.

         2. In the Analytics location field, specify the country/region of your organization.

         3. In the Cloud Firestore location field, specify where your Cloud Firestore data resides.

         4. Click Add Firebase.

3. Configure the FCM project as described in Working with the FCM service.

4. In your 1C:Enterprise mobile application, modify its code to use the FCM service for sending push notifications.

Working with the WNS service

IMPORTANT! The description of the developer's portal is valid at the document creation time.

When deploying and configuring the notification sender application in a customer's network, the implementation engineer of the application should perform the following actions:

1. Open Windows Dev Center (https://developer.microsoft.com/windows).

2. Click Dashboard.

3. From the Overview page, click Create a new app.

4. In the text box, type the name that you want to use for the application, and then select Check availability.

If the name is available, you will see a green checkmark.

5. Click Reserve product name.

6. Open Application Registration Portal (https://apps.dev.microsoft.com).

7. Locate the application you created and open its page.

8. On the application page, locate the values of the application secrets and the application security ID.

It is recommended to treat these values as confidential information.

9. Use these values as parameters when calling the GetAccessToken() method of the DeliverableNotificationSendManager object. As the method's ApplicationID parameter, use the application secrets. As the method's ApplicationKey parameter, use the application security ID.

The resulting token is used for sending notifications.

10. Provide the application secrets and the application security ID to the implementation engineer of the notification sender application. The engineer is to specify these values in the application's settings.

When working with WNS, the value of the DeliverableNotificationSubscriberID.ApplicationID the property includes a Push Notification Channel. It is the URI your mobile application uses to receive notifications. You send notifications by submitting POST requests to the address specified in the URI. The channel is bound to a particular application on a particular device.

Note that the value of the Push Notification Channel can be changed automatically from time to time. It is recommended for a mobile application to request a new Push Notification Channel every time it is launched and inform its notification delivery service about the channel. Anyway, the developer should treat the value of the DeliverableNotificationSubscriberID.ApplicationID property as a string with unknown contents and should not change its value.

Working with 1C Company's notification delivery service

The developer of the mobile application should perform the following actions:

1. Register the application in the notification delivery service the application is to use. If the application is to use several services, register it in all the services.

2. Save the artifacts each of the services provides.

3. Sign up on 1C Company's notification delivery service's web site (https://pushnotifications.1c.com/signup).

When signing up, you need to specify a mobile phone number. The service sends the verification code to this number. In the contact data, it is recommended to specify the contact data of your mobile application's developer.

4. To register your mobile application as the notification recipient, from the Push notifications menu, select Manage applications, click Register mobile application, specify your mobile application's name, and then click Save.

5. To connect the mobile application to the notification delivery services you need, do the following:

         1. In the Your mobile applications list, for your mobile application, click Connect to APNS, GCM, FCM or WNS.

         2. Depending on the service you need, click the button that corresponds to the service and specify parameters for working with the service.

  • APNS: Click + Connect to APNS and specify:

          · Your mobile application's ID

          · Your mobile application's certificate in .P12 format and its password

  • GCM: Click + Connect to GCM and specify:

           · Your mobile application's ID

  • FCM: Click + Connect to FCM and specify:

           · Your mobile application's ID

           · The value of the server key of the project registered in Firebase Console

  • WNS: Click + Connect to WNS and specify:

           · Your mobile application's ID

           · The value of your mobile application's application secrets obtained on Microsoft's dedicated site

         3. Click Save.

The notification sender developer does not need to perform any specific actions in 1C Company's notification delivery service.

The notification sender implementation engineer should perform the following actions:

1. Sign up on 1C Company's notification delivery service's web site (https://pushnotifications.1c.com/signup).

When signing up, you need to specify a mobile phone number. The service sends the verification code to this number. In the contact data, it is recommended to specify contact data of your information system's administrator.

2. To register your information system as a notification sender, from the Push notifications menu, select Notification senders, click Register sender, specify the sender's code, name, allowed IP addresses, and then click Save.

If you specify the IP addresses, the service allows sending notifications from these addresses only. Otherwise, the service allows sending notifications from any computer on which you are authorized in the service.

Note that it is a notification sender implementation engineer (not notification sender developer) who registers the notification sender in the service when configuring the sender instance in the customer's network.

As a result of the sender registration, the service generates a special access key.

3. To save the access key to the clipboard, click Copy key or first click Edit and then copy the value of the Sender API Key field to the clipboard.

This value is to be specified in the settings of a particular notification sender instance. It is used as an authentication key for sending notifications (the AuthenticationData parameter of the Send() method of the DeliverableNotificationSendManager) object).

It is recommended to treat this value as confidential information because if a third party gets access to this key, it lets them send push notifications on behalf of you provided that you have not specified particular IP addresses for the Sender API key.

The mobile application user should perform the following actions:

1. For the mobile application, specify the parameters of the exchange service the notification sender provides.

2. Initiate creating the ID for the notification recipient and sending the ID to the notification sender.

Sending notifications

The actions you perform to send notifications are almost identical for different services. The difference is in the values of parameters of the method that sends notifications. It is the Send() method of the DeliverableNotificationSendManager object that performs the sending.

1. Depending on the service, you use the following authentication data (the AuthenticationData parameter of the Send() method):
  • APNs - mobile application's certificate. On the computer with the notification sender installed, outgoing connections for IP ports 2195 and 2196 must be allowed.

  • GCM - mobile application's API key.

  • FCM - server key of the project registered in Firebase Console

  • WNS - the return value of the GetAccessToken() method of the DeliverableNotificationSendManager object.

  • 1C Company's notification delivery service - sender API key. Also, specify the value of the UseIntemediateService parameter to True.

2. If you send notifications by using several services at once, then as the authentication data you can use a key-value mapping where the service type (the value of the DeliverableNotificationSubscriberType enumeration) is used as a key and the data required for the corresponding service is used as a value.

Note however that is not possible to combine sending a notification via the APNs, GCM, FCM, or WNS service and via 1C Company's notification delivery service in one call to the Send() method. If the method's UseIntemediateService parameter is set to True, the method's AuthenticationData parameter can only accept a sender API key you get from 1C Company's notification delivery service.

3. The list of notification recipients is described with the DeliverableNotification object's Recipients the property, which you use as the first parameter of the Send() method.

4. When working with the WNS service, remember that the value of the access token (obtained via the GetAccessToken() method) is not permanent for the given application. You have to obtain it occasionally. To let you determine if there is a need to obtain an access token anew, use the InformationAboutDiliverableNotificationSendingProblems return parameter of the Send() method. If a problem occurs when sending notifications, this parameter contains a list of found problems. If there is a problem of the AuthenticationDataError type, you should obtain an access token anew and then repeat sending the notification.

How mobile applications process notifications

If a notification handler is not connected to the mobile application, the application saves the given notification in memory till the end of the user session and passes the notification to the handler once it is connected during the session. If there is no hander connected during the session, the notification is lost once the session ends.

Also, take into account the following peculiarities of how the mobile application works with notifications:

1. If the mobile application is active, the notification is immediately delivered to the application, at that the badge and sound alert are ignored.

2. If the mobile application is inactive at the moment the notification is delivered, the operating system displays the notification. If the user taps the notification, the operating system activates the corresponding application. If the user deletes the notification, the operating system does not inform the application about the notification. iOS 7 or earlier deletes a notification from the notification pane either if the user deletes it explicitly, or if new notifications of the given application displace this one.

3. If the mobile application works in background mode at the moment the notification is delivered, notification's processing depends on the operating system:

  • On iOS, the operating system passes the notification to the mobile application once the user selects it in the notification pane.

  • On Android, the operating system immediately passes the notification to the mobile application and displays it in the notification pane. Once the user taps the notification in the pane, the operating system activates the application but does not pass the notification to it anew.

  • On Windows, the operating system passes the notification to the mobile application only once the user selects it in the notification pane.

4. If your mobile application has several infobases installed, the application asks the user to switch to an appropriate target infobase. If the application cannot determine the target infobase, it displays the corresponding message.

Next page: Accessing fields from other fields using . (dot)


Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.