SelectC# Mobile Push API Reference for Realtime Apps

These docs are for version 3.8.7 of the C# SDK. To check out the docs for the latest version Click Here.
 

PubNub 4.0 for C# is our latest and greatest! Please click here for our PubNub 4.0 for C# docs and SDK.

PubNub 3.x for C# will encounter End Of Life (EOL) Aug 1st, 2018. All users currently on 3.x should begin migrating to 4.x. The 3.x SDK will continue to work. We will no longer support it and if you run into an issue, we will request that you upgrade to the latest version before solving the issue.

If you have questions about the PubNub for C# SDK, please contact us at support@pubnub.com.

PubNub's Mobile Push Gateway feature enables developers to bridge native PubNub publishing with 3rd-party push notification services including Google Android GCM (Google Cloud Messaging)/FCM (Firebase Cloud Messaging), Apple iOS APNs (Apple Push Notification service), and Microsoft Windows Phone MPNS (Microsoft Push Notification Service).

By using the Mobile Push Gateway, developers can eliminate the need for developing, configuring, and maintaining additional server-side components for third-party push notification providers.

Learn more about our Mobile Push Gateway here.


Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Enable push notifications on provided set of channels.
To run Adding Device to Channel you can use the following method(s) in the C# SDK
  1. ParameterTypeRequiredDescription
    channelstringYesThe channel to remove the push notifications
    pushTypePushTypeServiceYesPushTypeService.MPNS
    pushTokenstringYesDevice Id
    userCallbackCallback Method of Type TYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientErrorYesThis callback is called on an error event.
  2. ParameterTypeRequiredDescription
    channelstringYesThe channel to remove the push notifications
    pushTypePushTypeServiceYesPushTypeService.MPNS
    pushTokenstringYesDevice Id
    userCallbackCallback Method of Type objectYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientErrorYesThis callback is called on an error event.
string deviceId = "http://sn1.notify.live.net/throttledthirdparty/01.00/AQG2MdvoLlZFT7-VJ2TJ5LnbAgAAAAADAQAAAAQUZm52OkRFNzg2NTMxMzlFMEZFNkMFBlVTU0MwMQ";
pubnub.RegisterDeviceForPush <string>(channel:"my_channel", pushType:PushTypeService.MPNS, pushToken:deviceId, userCallback:DisplayReturnMessage, errorCallback:DisplayErrorMessage);
//NOTE: DisplayReturnMessage and DisplayErrorMessage are callback methods
[1, "Modified Channels"]

Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Request for all channels on which push notification has been enabled using specified pushToken.
To run Listing Channels For Device you can use the following method(s) in the C# SDK
  1. ParameterTypeRequiredDescription
    pushTypePushTypeServiceYesPushTypeService.MPNS
    pushTokenstringYesDevice Id
    userCallbackCallback Method of Type TYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientErrorYesThis callback is called on an error event.
  2. ParameterTypeRequiredDescription
    pushTypePushTypeServiceYesPushTypeService.MPNS
    pushTokenstringYesDevice Id
    userCallbackCallback Method of Type objectYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientErrorYesThis callback is called on an error event.
string deviceId = "http://sn1.notify.live.net/throttledthirdparty/01.00/AQG2MdvoLlZFT7-VJ2TJ5LnbAgAAAAADAQAAAAQUZm52OkRFNzg2NTMxMzlFMEZFNkMFBlVTU0MwMQ";
pubnub.GetChannelsForDevicePush<string>(pushType:PushTypeService.MPNS, pushToken:deviceId, userCallback:DisplayReturnMessage, errorCallback:DisplayErrorMessage);
//NOTE: DisplayReturnMessage and DisplayErrorMessage are callback methods
The output below demonstrates the response to a successful call:
will contain a list of channels registered for push notifications

Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Disable push notifications on provided set of channels.
To run Removing Device From Channel you can use the following method(s) in the C# SDK
  1. ParameterTypeRequiredDescription
    channel
    string
    Yes
    The channel to remove the push notifications
    pushType
    PushTypeService
    Yes
    PushTypeService.MPNS
    pushToken
    string
    Yes
    Device Id
    userCallback
    Callback Method of Type T
    Yes
    This callback is called on success event.
    errorCallback
    Callback Method of Type PubnubClientError
    Yes
    This callback is called on an error event.
  2. ParameterTypeRequiredDescription
    channel
    string
    Yes
    The channel to remove the push notifications
    pushType
    PushTypeService
    Yes
    PushTypeService.MPNS
    pushToken
    string
    Yes
    Device Id
    userCallback
    Callback Method of Type object
    Yes
    This callback is called on success event.
    errorCallback
    Callback Method of Type PubnubClientError
    Yes
    This callback is called on an error event.
string deviceId = "http://sn1.notify.live.net/throttledthirdparty/01.00/AQG2MdvoLlZFT7-VJ2TJ5LnbAgAAAAADAQAAAAQUZm52OkRFNzg2NTMxMzlFMEZFNkMFBlVTU0MwMQ";
pubnub.RemoveChannelForDevicePush<string>(channel:"my_channel", pushType:PushTypeService.MPNS, pushToken:deviceId, userCallback:DisplayReturnMessage, errorCallback:DisplayErrorMessage);
//NOTE: DisplayReturnMessage and DisplayErrorMessage are callback methods
The output below demonstrates the response to a successful call:
[1, "Modified Channels"]

Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Disable push notifications from all channels registered with the specified pushToken.
To run Remove all push notifications you can use the following method(s) in the C# SDK
  1. ParameterTypeRequiredDescription
    pushType
    PushTypeService
    Yes
    PushTypeService.MPNS
    pushToken
    string
    Yes
    Device Id
    userCallback
    Callback Method of Type T
    Yes
    This callback is called on success event.
    errorCallback
    Callback Method of Type PubnubClientError
    Yes
    This callback is called on an error event.
  2. ParameterTypeRequiredDescription
    pushType
    PushTypeService
    Yes
    PushTypeService.MPNS
    pushToken
    string
    Yes
    Device Id
    userCallback
    Callback Method of Type object
    Yes
    This callback is called on success event.
    errorCallback
    Callback Method of Type PubnubClientError
    Yes
    This callback is called on an error event.
string deviceId = "http://sn1.notify.live.net/throttledthirdparty/01.00/AQG2MdvoLlZFT7-VJ2TJ5LnbAgAAAAADAQAAAAQUZm52OkRFNzg2NTMxMzlFMEZFNkMFBlVTU0MwMQ";
pubnub.UnregisterDeviceForPush<string>(pushType:PushTypeService.MPNS, pushToken:deviceId, userCallback:DisplayReturnMessage, errorCallback:DisplayErrorMessage);
//NOTE: DisplayReturnMessage and DisplayErrorMessage are callback methods
The server responds with a status code of 200.