Implement additional services
Once the package has been configured using either approach, you need to implement platform specific services in order for the SDK to function properly. The interfaces to do this are provided by the API SDK package but must be implemented by you.
ILocalStorageService
Use the following parameters to configure the service:
string Load(string key)
string Load(string key, string defaultValue);
int LoadInt(string key);
void Save(string key, string value);
void Save(string key, int value);
bool ClearAll();
bool Remove(string key);
ISecureStorageService
Use the following parameters to configure this service:
string Load(string key);
bool Save(string key, string value);
bool Remove(string key);
bool ClearAll();
INetworkService
This is an optional service, used to determine if a network request should be sent or not. If this method returns false, the SDK will attempt to grab a cached version of the response. Otherwise, if true, the SDK will make the request as normal.
Note
If IsOnline() returns
false
and you have configured caching off, then the request will always returnnull
.
bool IsOnline();
ITrackingService
You should add your analytics service implementation here. If you do not have an analytic service, you should still implement this interface and leave the methods blank.
Use the following parameters to configure the service:
ISessionService SessionService { get; }
void Initialize();
void TrackEvent(AnalyticsEvent analyticsEvent);
void TrackException(Exception exception, Dictionary<string, string> properties = null);
void ForceCrash();
void SetUserID(string userId);
ICommerceAPIServiceProvider
Although you are able to inject the dependencies you need manually, this interface helps condense your class's constructor size. You must implement the accessor methods through IServiceProvider
's GetService(Type). If you are using MvvmCross, you can resolve the dependency through Mvx.IoCProvider.Resolve<IService>();
Updated over 2 years ago