Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Creating a push channel

The sample app creates a push channel to the PPG to
receive push messages. The app needs to create a channel only the
first time it starts, or if the channel was destroyed and you want
to start receiving push messages again.

If you chose to subscribe with the Push Service SDK when you configured the sample app, the
server-side push initiator requires a username and password that it
authenticates before allowing the subscription. The sample app
provides a Register screen where the user can type any username and
password. For your app, check with your push content provider to get
a valid username and password.

You can open the Register screen by tapping Register at
the bottom of the device screen. The Register screen appears.

After you type the username and password and tap Submit,
the sample app tries to create a channel.

If you don't subscribe with the Push Service SDK, you don't need to provide a username and
password. You can tap Register and Submit, and the sample app tries
to create a channel.

Call createChannel()

The sample app calls createChannel() to create a channel to the PPG.
The createChannel() function
includes the createChannelCallback
callback function as an argument. If the channel creation is
successful, createChannelCallback
returns a token that isn't null. The token represents the device and
the app that receives push messages. You need to communicate the
token to the server-side push initiator so that the server-side app
can use the token to send push messages to the client-side app. If
the channel creation fails, the token is null, and you should ignore
it.

The createChannelCallback callback function shows the
error handling if the create channel operation fails. In your app,
you might want to handle the errors differently. For example, you
might want to retry an operation first before displaying an error
message. The API Reference lists the
possible actions that you can take for each error constant. The API
Reference also shows which error codes apply to which function
calls.

Call subscribeToPushInitiator()

If the channel creation is successful, and you subscribe
with the Push Service SDK, the sample app calls subscribeToPushInitiator() to
subscribe with the server-side app. The subscribe function passes in
the token to the server-side app, along with the username and
password that you typed on the Register screen. If you don't
subscribe with the Push Service SDK, the sample app doesn't call subscribeToPushInitiator().