C#C# V4 Mobile Push API Reference for Realtime Apps

Go to Storage & Playback


 

These docs are for PubNub 4.0 for C# which is our latest and greatest! For the docs of the 3.x versions of the SDK, please check the links: C#, Windows 8, Windows 8.1, ASP.Net, Windows Phone 8, Windows Phone 8.1, Xamarin.iOS, Xamarin.Android, Xamarin.Mac and C# PCL.

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

Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page 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# V4 SDK
  1. ParameterTypeRequiredDescription
    PushTypePNPushTypeYesAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    ChannelsArrayYesAdd push notifications on the specified Channels.
    DeviceIdstringYesDevice id.
    QueryParamDictionary<string, object>OptionalDictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose.
    AsyncPNCallbackDeprecatedPNCallback of type PNPushAddChannelResult.
    ExecutePNCallbackYesPNCallback of type PNPushAddChannelResult.
pubnub.AddPushNotificationsOnChannels()
    .PushType(PNPushType.GCM)
    .Channels(new string[] { 
        "ch1",
        "ch2",
        "ch3"
    })
    .DeviceId("googleDevice")
    .Execute(new DemoPushAddChannel());

public class DemoPushAddChannel : PNCallback<PNPushAddChannelResult> {
    public override void OnResponse(PNPushAddChannelResult result, PNStatus status) {
    }
}
The AddPushNotificationsOnChannels() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError().
Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page 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# V4 SDK
  1. ParameterTypeRequiredDescription
    DeviceIdstringYesDevice id.
    PushTypePNPushTypeYesAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    QueryParamDictionary<string, object>OptionalDictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose.
    AsyncPNCallbackDeprecatedPNCallback of type PNPushListProvisionsResult.
    ExecutePNCallbackYesPNCallback of type PNPushListProvisionsResult.
pubnub.AuditPushChannelProvisions()
    .DeviceId("googleDevice")
    .PushType(PNPushType.GCM)
    .Execute(new DemoPushListProvisionChannel());

public class DemoPushListProvisionChannel : PNCallback<PNPushListProvisionsResult> {
    public override void OnResponse(PNPushListProvisionsResult result, PNStatus status) {
    }
}
The AuditPushChannelProvisions() operation returns a PNPushListProvisionsResult which contains the following property:
Property NameTypeDescription
ChannelsList<string>List of channels subscribed for push notifications.
Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page 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# V4 SDK
  1. ParameterTypeRequiredDescription
    DeviceIdstringYesDevice id.
    ChannelsArrayYesRemove push notifications on the specified Channels.
    PushTypePNPushTypeYesAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    QueryParamDictionary<string, object>OptionalDictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose.
    AsyncPNCallbackDeprecatedPNCallback of type PNPushRemoveChannelResult.
    ExecutePNCallbackYesPNCallback of type PNPushRemoveChannelResult.
pubnub.RemovePushNotificationsFromChannels()
    .DeviceId("googleDevice")
    .Channels(new string[] { 
        "ch1",
        "ch2", 
        "ch3" 
    })
    .PushType(PNPushType.GCM)
    .Execute(new DemoPushRemoveChannel());

public class DemoPushRemoveChannel : PNCallback<PNPushRemoveChannelResult> {
    public override void OnResponse(PNPushRemoveChannelResult result, PNStatus status) {
    }
}
The RemovePushNotificationsFromChannels() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError().
Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page 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 which is registered with specified pushToken.
To run Remove all push notifications you can use the following method(s) in the C# V4 SDK
  1. ParameterTypeRequiredDescription
    DeviceIdstringYesDevice id
    PushTypePNPushTypeYesAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    QueryParamDictionary<string, object>OptionalDictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose.
    AsyncPNCallbackDeprecatedPNCallback of type PNPushRemoveAllChannelsResult.
    ExecutePNCallbackYesPNCallback of type PNPushRemoveAllChannelsResult.
pubnub.RemoveAllPushNotificationsFromDeviceWithPushToken()
    .DeviceId("googleDevice")
    .PushType(PNPushType.GCM)
    .Execute(new PNPushRemoveAllChannelsResultExt((r, s) => {
        Console.WriteLine(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
    }));
The RemoveAllPushNotificationsFromDeviceWithPushToken() operation returns a PNPushRemoveAllChannelsResult which contains the following property:
Property NameTypeDescription
PNPushRemoveAllChannelsResultObjectReturns empty object.
PNStatusObjectReturns status of request if error occured or not.

Go to Objects (BETA)