Unofficial Content
  • This documentation is valid for:

28/01/2016 Parse has been deprecated by Facebook and will be shutdown on January 2017.

For sending Push Notifications, see HowTo: Push Notifications using an External Provider

It allows sending Push Notifications to iOS, Android, Windows devices on any platform.

Advantages:

  • Infinite scalability (to send thousands of notifications per second)
  • Free (up to 1,000,000 installations)
  • Control panel for managing users and send notifications
  • No own infrastructure needed for Push
  • Independence from Push Platforms

Requirements:

  • Registration required in Parse.com and greater configuration.

How it Works

In order to send notifications to your apps using Parse, you need to import this XPZ. This will add to your Knowledge Base the following structure/objects:

  • ParsePush
    • ParsePushConfig
      • ParsePushConfig - Here you have to set the Parse.com notifications configuration.
    • ParsePushInternal
      • ParseInterfaceRequest
      • ParseJsonEncode
      • ParseSendMessage
      • ParseSetDevice
      • ParseSetError
    • ParsePushOperations
      • ParseSendMessageChannel
      • ParseSendMessageDevice
      • ParseSubscribehannels
      • ParseSubscribeDevice
      • ParseSubscribeDevice2
      • ParseUnSubscribeChannels
    • ParsePushSDTs
      • GXPushOperationResult
      • GXPushParseMessage

Register Devices

The procedure which handles this in GeneXus is NotificationsRegistrationHandler, on this procedure we need to add this lines:

ParsePushConfig.Call(&PushConfig)
ParseSubscribeDevice.Call(&PushConfig,&DeviceToken,&DeviceType,&ProviderDeviceId,&GXPushOperationResult)
if (&GXPushOperationResult.Success)
    msg("Device subscribed ok to Parse.com Cloud!", status)
else
   msg("Error:" + &GXPushOperationResult.ErrDescription, status)
endif
  • ParsePushConfig to get the Configuration needed to call the subscribe device procedure -this variable must be based on the Properties Data Type.
  • ParseSubscribeDevice or ParseSubscribeDevice2 -depending on the data we want to save.
    • The second one includes the parameter Device Data -Device Information that will be sent to Parse.com in order to be shown within Parse.com Devices Dashboard, for better device identification.

Subscribe Channels

For subscribing the devices to the channels use the following code:

&Channels.Clear()
&Channels.Add(!"GROUP1")
&Channels.Add(!"GROUP2")

ParseSubscribeChannels(&Config, &ProviderDeviceId, &Channels, &GXPushOperationResult)

if (&GXPushOperationResult.Success)
    msg("Device channels sucessfully added")
else
   msg("Error:" + &GXPushOperationResult.ErrDescription)
endif

Send Notifications to Devices

ParseSendMessageDevice(&Config, &GXPushParseMessage, &ProviderDeviceId, 2, &GXPushOperationResult)
msg(&GXPushOperationResult.ToJson(), status)

Send Notifications to Channels

ParseSendMessageChannel(&Config, &GXPushParseMessage, &Channels, 2, &GXPushOperationResult)
msg(&GXPushOperationResult.ToJson(), status)

Error Codes

  • 1: Unkown error. See Error Description for more details.
  • 3: Parse Object ID is required: Method parameter "Parse Object ID" (Provider DeviceId) was not set. 
  • 4: iOS invalid device token: Device Token specified is not valid.
  • 5: "GCMSenderId is required". GCMSenderId must be specified in ParsePush Config. 
  • 6: Device Token is required. 
  • 7: No channels specified. At least 1 channel must be set. 
  • 10: "Application ID parameter is Required": ApplicationId must be specified in ParsePush Config. 
  • 11: "REST API Key parameter is Required": RestAPIKey must be specified in ParsePush Config. 
  • 112: Invalid Channel Name: Error code indicating an invalid channel name. A channel name is either an empty string (the broadcast channel) or contains only a-zA-Z0-9_* characters and starts with a letter
  • 114: Invalid Device Token
  • 140: Exceeded_Quota: Error code indicating that an application quota was exceeded.

Availability

This XPZ works for Android since GeneXus X Evolution 3 Upgrade 4 and for iOS since  GeneXus X Evolution 3 Upgrade 3.

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant