C#C# V4 SDK Troubleshooting 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.

 Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. Not setting the UUID can significantly impact your billing if your account uses the Monthly Active Users (MAUs) based pricing model, and can also lead to unexpected behavior if you have Presence enabled.

PNConfiguration config = new PNConfiguration();
config.LogVerbosity = PNLogVerbosity.BODY;
config.PubnubLog = new PlatformPubnubLog(); //Capture the log information 
public class PlatformPubnubLog : IPubnubLog {
    private string logFilePath = "";

    public PlatformPubnubLog() {
        // Get folder path may vary based on environment
        string folder = System.IO.Directory.GetCurrentDirectory(); //For console
        //string folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // For iOS
        System.Diagnostics.Debug.WriteLine(folder);
        logFilePath = System.IO.Path.Combine(folder, "pubnubmessaging.log");
        Trace.Listeners.Add(new TextWriterTraceListener(logFilePath));
    }

    public void WriteToLog(string log) {
	    //Save to text file or DB or any storage
        Trace.WriteLine(log);
        Trace.Flush();
    }
}