Skip to content

Push Notifications Overview

Chidi Okwudire edited this page Jan 24, 2017 · 9 revisions

This page describes how to set your CodenameOne app up to use push notification services provided by Parse Server. Parse simplifies the process of configuring push notifications while giving app developers sufficient flexibility in creating an implementation that is customized to meet their app's requirements. Parse4CN1 now exposes this power to CN1 apps!

Overview of Push Support in Parse4CN1

Before getting into the details, here's an overview of the main push features available to CN1 apps via parse4cn1.

Feature Supported Platforms Remarks
Sending push messages from your app Android, iOS This includes targeted push notifications to channels and/or using advanced queries. Also possible via Parse dashboard
Receiving incoming push messages including status bar notifications and/or callbacks indicating whether the message was received in foreground or background if supported by the platform Android, iOS Callbacks vary per platform and must be implemented in the app as explained in the setup guides
Silent (a.k.a. hidden) push notifications Android, iOS
Detecting opening of the app via a push notification if implemented Android, iOS Silent push notifications are not tracked by default

For some platforms, there are additional constraints which are described below.

Platform CN1 subscription Other requirements
Android Any None
iOS Any Mac for generating the push certificate (see setup guide below for more details)

What are you waiting for? Get started with push notifications right now and enjoy the above benefits and more!

If you implement interesting tweaks that you think might be useful to others, or face any difficulties, get in touch by filing a Github issue or via the CN1 discussion forum. Thanks in advance!

Parse4CN1 Push Notification Architecture

Push notification is very native business - Apple, Google, Microsoft just to name a few all how their own push architectures. That makes setting up push notifications painful. Parse hides a lot of that pain by providing:

  • Native Android, iOS and Windows Phone SDKs for subscribing for and receiving push. Note as of January 2017, Parse Server does not yet support push for Windows Phone.
  • Options for sending push messages via the Parse console, REST API and/or native SDKs
  • Comprehensive guides and tutorials for setting up push in your app

Although the above resources are very helpful, there are still some details you need in order to successfully get push via Parse Server up and running in your CN1 app. Before going into the details, it's perhaps useful to have an overview. Thus, this section describes the push notification architecture of parse4cn1. If you're not interested in how things work internally, you can skip to the "What's next" section.

Architecture Overview

Parse4CN1 harnesses the infrastructure provided by Parse to integrate push services into CodenameOne apps. Parse4CN1 attempts to do as much as possible in a cross-platform manner. However, for push notifications, it is impossible to do everything in a cross-platform fashion. As such, parse4cn1 has been extended with Parse native SDK integration. The following figure gives an overview of the push notification architecture in parse4cn1.

Note that the /native/<platform> folders contain instructions on how to update the corresponding Parse SDK if ever needed.

parse4cn1 push notification architecture

Two push-related classes ParseInstallation and ParsePush are included in the cross-platform layer of parse4cn1.

ParseInstallation

A ParseInstallation represents an installation of your app on a specific device. Creation of Parse installation objects is delegated to the native Parse SDKs (which know exactly what fields are required in an installation on each platform to enable push support for that platform).

Once the Parse installation has been created, information about the installation is required in the cross-platform layer to enable retrieval and modification of the installation. To accomplish this, parse4cn1 uses CN1's native interfaces for retrieving the installationId for Android and iOS (and triggering creation of the installation, if necessary). After the ParseInstallation has been successfully created, everything related to installation management (retrieval, updating, etc.) can again be done in the cross-platform layer of parse4cn1 via the Parse REST API.

ParsePush

Without exception, setting up of push notifications occurs in the Parse native SDKs on all platforms. In this regard, all the ParsePush class does is to provide methods for uniformly handling incoming push notifications and delivering the payload to the app via the IPushCallback interface.

However, ParsePush has another very important function: It exposes the functionality for sending push messages via the Parse REST API without any dependence on the Parse native SDKs. It also features the advanced targeting push messaging provided by Parse. See push notification usage examples for more details.

Note that since Parse Server requires the master key for sending push notifications, a cloud function is required to bridge the gap.

What next?

The path your about to take is not for the faint-hearted. Managing your own push is fun, gives you flexibility but is certainly by far not the easiest thing to get up and running. However, we're here to help. To start using push, check out the step-by-step parse4cn1 push notification setup guide(s) below for the platform(s) of your interest. These setup guides describe a reference implementation. However, depending on your app's requirements, you might want to tweak the implementation to meet your specific needs.

If you implement interesting tweaks that you think might be useful to others, duty demands that you share, e.g. via the CN1 discussion forum or by filing a Github issue so that this wiki can be updated. Thanks in advance!

Once you're done with setting up, you might want to have a look at the push notification usage examples.

Enjoy!

Clone this wiki locally