iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Most of third party mobile cloud platforms provide lots of powerful services, such as Storage, Push Notification, Audio/Video Encoding, LBS, Social Share, Analysis, Feed Back etc.. As you know, they usually provide iOS & Android SDKs, sometimes javascript SDK. My question is
How can we write our C# code to wrap these iOS/Android class libraries, and integrate with Crosslight MVVM pattern, such as write our own Mobile Service (only invoked in ViewModel layer), just like Crosslight mobile service did? Can you give us any ideas or samples?
I started to create a simple sample by using Blank project template.
Next, I added an interface called ICustomService which inherits IMobileComponentService. The snippet code below shows how the interface is declared in ICustomService.cs file in the Core project.
using Intersoft.Crosslight.Mobile; namespace CustomService.Core.Custom { public interface ICustomService : IMobileComponentService { void DoSomething(); } }
In the SimpleViewModel class, ShowToast function is modified by resolving CustomService via IoC (injection of Container) technique. If customService is not null, invokes DoSomething() method.
private void ShowToast(object parameter) { //this.ToastPresenter.Show("You entered: " + this.NewText); //this.GreetingText = this.NewText; ICustomService customService = ServiceProvider.GetService<ICustomService>(); //resolve CustomService via IoC (injection of Container) if (customService != null) { customService.SetOwner(this); //needed for Android platform only customService.DoSomething(); } }
Next, we need to register the custom service in the AppInitializer class, specifically in the InitializeServices method.
public void InitializeServices(IApplicationHost appHost) { ServiceProvider.AddService<ICustomService, CustomiOSService>(); }
Please note that we need to repeat this step for each platform (Android, iOS, Windows Phone, and Windows StoreApp).
Last, implement DoSomething method for each platform. In the sample, what DoSomething doing is very easy, it shows "Custom Service" alert.
using CustomService.Core.Custom; using Intersoft.Crosslight.iOS; using MonoTouch.UIKit; namespace CustomService.iOS.Custom { public class CustomiOSService : IOSMobileComponentServiceBase, ICustomService { public void DoSomething() { UIAlertView alert = new UIAlertView("Custom service", "Custom Service", null, "OK", null); alert.Show(); } } }
The sample can be downloaded in https://onedrive.live.com/download?resid=A29317908CEA783A%21408. Please let us know whether this help or not.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname