Push Notifications

File: JVE.Pushes.pas Inheritance: TComponent ⬅ TJVEPushNotification

This component implements the Push Notifications support, with regard to the Operating System integration. Push notifications support, provided below, does not work in Windows or in iOS Simulator (i.e. only Android and iOS Devices and Mac OS X 10.7 or later).

Push notifications are singleton by design. Care should be taken to only ever have one instance of TJVEPushNotification (or any descendant thereof) ever created within the app.

This class provides operating system integration, but not the communication with your server-side (for a complete implementation, which could also be used as an example of server integration, see PushWoosh Service Integration section below). This component exposes the following properties:


  • AndroidSenderId – GCM Sender ID – no longer used (kept for backward compatibility).
  • Platforms – the list of platforms, on which this component is operational.
  • Types – the list of notifications, for which the component is registering.
  • ClearBadgeOnStart – setting this to True will instruct the application to clear the app icon badge at the start of the app.


Additional functionality provided by the component is the ability to convert Apple’s APN token to Google’s FCM token (for iOS). To enable this, set the following properties:

  • FCMConversionApiKey – Server API key for the Google project.
  • FCMConversionIsSandbox – True will use the sandbox account; False – production.

Leave FCMConversionApiKey property empty, if you want to receive Apple token as is. Notice, if you receive error -1012, this means that the Api Key is invalid or does not match the Bundle Identifier of the application.


This component exposes no methods. The following events are available:

  • OnToken – this event is invoked once a push notification token is available for your app. Notice, the fact that you get the token does not mean that the user agreed to accept them.
  • OnError – this event is invoked, if the operating system failed to get a valid token for the app. An error message is provided as a parameter; the default behavior is to present it.
  • OnReceived – this event is called for each push notification, received from the server. The push notification details are provided within the Push parameter (see below); OnAppStart indicates whether the app was started to take care of this notification (rather than receiving the notification while the app was already running). The default behavior is to present the notification message in a standard message box.


The Push parameter sent to the OnReceived event is actually a TStrings descendant. You can use the standard Values property to access the content of the notification. This descendant provides the following functions to access standard notification details:

  • GetMessage – returns the notification text.
  • GetBadge – returns the notification requested badge number.
  • GetSound – returns the sound to play along the notification.
  • GetNewsstand – returns True, if this is a newsstand content availability notification.

The format of the string list is based on the original Apple generated dictionary, converted using the Apple Dictionary to String List Converter (see Other Utilities section below).

Further implementations for specific services can introduce class helpers to provide more standard readers (like the PushWoosh Service Integration does).


If you have problems making push notifications work, examine the JVE.Pushes.pas file header, which contains a list of steps, you should take to make them work.