/// <param name="pushAppId"> The Push Application ID Registered with the server.</param>
public static void PushServiceConnect(string pushAppId)
{
- PushImpl.Instance.PushServiceConnect(pushAppId);
+ PushImpl.PushServiceConnect(pushAppId);
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public static void PushServiceDisconnect()
{
- PushImpl.Instance.PushServiceDisconnect();
+ PushImpl.PushServiceDisconnect();
//PushImpl.Reset();
}
/// </returns>
public static Task<ServerResponse> PushServerRegister()
{
- return PushImpl.Instance.PushServerRegister();
+ return PushImpl.PushServerRegister();
}
/// <summary>
/// </returns>
public static Task<ServerResponse> PushServerUnregister()
{
- return PushImpl.Instance.PushServerUnregister();
+ return PushImpl.PushServerUnregister();
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public static void GetUnreadNotifications()
{
- PushImpl.Instance.GetUnreadNotifications();
+ PushImpl.GetUnreadNotifications();
}
/// <summary>
/// </returns>
public static string GetRegistrationId()
{
- return PushImpl.Instance.GetRegistrationId();
+ return PushImpl.GetRegistrationId();
}
internal static void StateChange(PushConnectionStateEventArgs args)
namespace Tizen.Messaging.Push
{
- internal class PushImpl
+ internal static class PushImpl
{
private static readonly object _lock = new object();
- private static PushImpl _instance;
private static Interop.PushClient.VoidStateChangedCallback stateDelegate = null;
private static Interop.PushClient.VoidNotifyCallback notifyDelegate = null;
private static Interop.PushClient.VoidResultCallback registerResult = null;
private static Interop.PushClient.VoidResultCallback unregisterResult = null;
- internal static PushImpl Instance
- {
- get
- {
- lock (_lock)
- {
- if (_instance == null)
- {
- Log.Info(Interop.PushClient.LogTag, "Creating New Instance");
- _instance = new PushImpl();
- }
- return _instance;
- }
- }
- }
-
- internal PushImpl()
- {
- // Empty
- }
- private IntPtr _connection;
+ private static IntPtr _connection;
- internal void PushServiceConnect(string pushAppId)
+ internal static void PushServiceConnect(string pushAppId)
{
stateDelegate = (int state, string err, IntPtr userData) =>
{
}
}
- internal void PushServiceDisconnect()
+ internal static void PushServiceDisconnect()
{
Interop.PushClient.ServiceDisconnect(_connection);
Log.Info(Interop.PushClient.LogTag, "PushServiceDisconnect Completed");
}
- internal async Task<ServerResponse> PushServerRegister()
+ internal static Task<ServerResponse> PushServerRegister()
{
Log.Info(Interop.PushClient.LogTag, "Register Called");
var task = new TaskCompletionSource<ServerResponse>();
{
Log.Error(Interop.PushClient.LogTag, "Register callback was already registered with same callback");
task.SetException(PushExceptionFactory.CreateResponseException(Interop.PushClient.ServiceError.OpearationFailed));
- return await task.Task;
+ return task.Task;
}
registerResult = (Interop.PushClient.Result regResult, IntPtr msgPtr, IntPtr userData) =>
registerResult = null;
}
}
- return await task.Task;
+ return task.Task;
}
- internal async Task<ServerResponse> PushServerUnregister()
+ internal static Task<ServerResponse> PushServerUnregister()
{
var task = new TaskCompletionSource<ServerResponse>();
unregisterResult = (Interop.PushClient.Result regResult, IntPtr msgPtr, IntPtr userData) =>
{
task.SetException(PushExceptionFactory.CreateResponseException(result));
}
- return await task.Task;
+ return task.Task;
}
- internal string GetRegistrationId()
+ internal static string GetRegistrationId()
{
string regID = "";
Interop.PushClient.ServiceError result = Interop.PushClient.GetRegistrationId(_connection, out regID);
return regID;
}
- internal void GetUnreadNotifications()
+ internal static void GetUnreadNotifications()
{
Interop.PushClient.ServiceError result = Interop.PushClient.RequestUnreadNotification(_connection);
if (result != Interop.PushClient.ServiceError.None)
}
}
- internal static void Reset()
- {
- lock (_lock)
- {
- Log.Info(Interop.PushClient.LogTag, "Making _instance as null");
- _instance = null;
- }
- }
}
}