C#C# V3 to C# V4 Migration Guide

 

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.

  • V3 exposes PubNubMessaging.Core
  • V4 exposes PubnubApi
  • V3 initiates via:
    Pubnub(string publishKey, string subscribeKey, string secretKey, string cipherKey, bool sslOn)
  • V4 initiates via:
    Pubnub(PNConfiguration config)
  • V3 has DetailedHistory request.
  • V4 has History request.
  • V3 contains all arguments(with few overloaded) in the same generic method call:
    pubnub.DetailedHistory<string>(channel:"hi", count: 100, includeToken: true, userCallback: DisplayReturnMessage, errorCallback: DisplayErrorMessage)
  • V4 uses fluent style method calls.
    pubnub.History()
        .Channel("hi")
        .Count(100)
        .IncludeTimetoken(true)
        .Async(new PNHistoryResultExt((result, status) => {
        }));
  • V3 sends the response either as string or object. User needs to parse the output of callback.
  • V4 sends the response as static object(Eg. PNHistoryResult, PNPublishResult) based on the request.
  • V3 subscribe supports string or object types. It does not support custom classes.
  • V4 subscribe supports custom classes.
  • V3 publish supports JSON serialized message with pubnub.EnableJsonEncodingForPublish = false.
  • V4 publish do not support anymore with serialized JSON messages. SDK expects full object as the message payload.
  • V3 exposes the connect/disconnect callbacks on subscribe.
  • V4 exposes the functionality via the listener on status portion of the listener, please listen to PNConnectedCategory/PNDisconnectedCategory on the status category.
  • V3 exposes Presence() method for connecting/disconnect presence subscribes.
  • V4 exposes the Presence functionality as part of Subscribe. Use WithPresence to enable presence. Presence callback handled via the listener on presence portion of the listener, please listen to PNPresenceEventResult on the Presence callback.
  • V3 exposes logging capability through config appSettings(Non-PCL) and through pubnub. SetPubnubLog(IPubnubLog pubnubLog) method.
  • V4 exposes logging capability through PNLogVerbosity.BODY of PNConfiguration. IPubnubLog needs to be implemented and set PubnubLog of PNConfiguration.
  • V3 by default sets EnableResumeOnReconnect to true to re-try connect when interne/network fails.
  • V4 by default sets PNReconnectionPolicy.NONE for ReconnectionPolicy of PNConfiguration.