FeedHenry C#/.NET SDK (WP and Xamarin)
HTML C# JavaScript Other
Clone or download
Latest commit 3f6cddb Mar 28, 2018
Permalink
Failed to load latest commit information.
Dist Workaround for issue with installing FH.SDK on the latest Xamarin.iOS… Mar 7, 2018
Documentations Remove error in doc generation Mar 30, 2017
FHSDK deserialse to domain class rirght from the response Apr 7, 2017
FHSDKPhone add documentation generation Oct 6, 2016
FHSDKPortable add documentation generation Oct 6, 2016
FHXamarinAndroidSDK fix the release process Oct 5, 2016
FHXamarinIOSSDK add documentation generation Oct 6, 2016
licenses Add licenses folder Mar 28, 2018
test-android deserialse to domain class rirght from the response Apr 7, 2017
test-ios deserialse to domain class rirght from the response Apr 7, 2017
tests-phone deserialse to domain class rirght from the response Apr 7, 2017
tests-xamarin-utils changed to use xunit instead of nunitlite, because of `async Task` me… Jun 1, 2016
tests deserialse to domain class rirght from the response Apr 7, 2017
xamarin-component/fh-dotnet-sdk move projects May 31, 2016
.gitignore clean documentation release process Mar 27, 2017
.gitmodules remove test app Dec 2, 2015
CHANGELOG.md use the hash value of the pending record as the uid for newly created… Sep 22, 2015
FHSDK-xamarin-studio.sln add solution for xamarin studio that doesn't include the projects it … May 31, 2016
FHSDK.sln fix the release process Oct 5, 2016
FHSDK.userprefs changed to use Xamarin.IOS Jan 20, 2016
LICENSE Update LICENSE to Apache License Dec 17, 2015
ReadMe.md clean documentation release process Mar 27, 2017
SyncClient.md fix wrong links in read files Jun 26, 2014
UpgradeLog.htm split into two projects Mar 30, 2015
VERSION.txt use the hash value of the pending record as the uid for newly created… Sep 22, 2015
appveyor.yml changed to use xunit instead of nunitlite, because of `async Task` me… Jun 1, 2016
copyIOSLibs.sh fixed folder Oct 6, 2016
copyLibs.bat add the .pdb and fix the source location Oct 6, 2016
licenses.txt add licenses.txt file Apr 14, 2015

ReadMe.md

FeedHenry C#/.NET SDK

Build status

FeedHenry native .NET SDK for Windows Phone 8+ and Xamarin platform. It supports Portable Class Library (PCL) projects as well.

Install

You can install the SDK to your project either automatically (using NuGet) or manually.

NuGet (Recommended)

FH SDK is available on NuGet: https://www.nuget.org/packages/FH.SDK/. If you are using the NuGet plugin on Visual Studio or Xamarin Studio, please search for FH.SDK. NuGet will install dependecy libraries automatically.

Manually

The .dll assembly files can be found in the Distribution directory. Please use the .dll files inside the folder that is corresponding to your project's target platform. The SDK is depending on Json.Net and Microsoft HTTP Client Libraries. You need to install the assemblies of those libraries as well if they are not available in your project.

Usage

FHClient.Init

Initialise the SDK. Normally it should be called immediately after the app finish initialising. FHClient is available in the following namespaces:

  • FHSDK.Phone - For WP8
  • FHSDK.Droid - For Android
  • FHSDK.Touch - For iOS

Depending on your app's build target, only one of these name spaces should be available to your app.

The main reason for having the same FHClient class defined in different name spaces is to ensure that the platform-specific assembly file is loaded correctly.

try {
  bool inited = await FHClient.Init();
  if(inited) {
    //Initialisation is successful
  }
}
catch(FHException e) {
  //Initialisation failed, handle exception
}

FH.Cloud

Invoke a cloud function. Can be used in PCL projects.

FHResponse response = await FH.Cloud("api/echo", "GET", null, null);
if(null == response.Error)
{
  //no error occured, the request is successful
  string rawResponseData = response.RawResponse;
  //you can get it as JSONObject (require Json.Net library)
  JObject resJson = response.GetResponseAsJObject();
  //process response data
}
else
{
  //error occured during the request, deal with it.
  //More infomation can be access from response.Error.InnerException
}

FH.Auth

Call the FeedHenry Authentication API with the given policyId. This is normally used for OAuth type authentications. The user will be prompted for login details and the the login result will be returned. Can be used in PCL projects.

string authPolicy = "TestGooglePolicy";
FHResponse res = await FH.Auth(authPolicy);
if (null == res.Error)
{
    //auth is successful
}
else
{
    //auth failed
}

FH.GetCloudHost

Return the url of the cloud host the app is communicating with. Can be used in PCL projects.

FH.Act (Deprecated)

Invoke a cloud function which you have defined in cloud/main.js (the old way). Can be used in PCL projects.

For full list of APIs, please check FH .NET SDK API References.

Sync Client

See Sync Client Usage Guide.

Solution Structure

The complete FH .NET SDK contains four projects:

  • FHSDK

    A PCL library contains core code. It is required by all the other three projects. Most the the APIs are implemented here. It contains a few interface definitions which are implemented in each platform's project. Another important function of this library is to automatically figure out the correct implementions for the inferfaces when running on devices (see code in FHSDK/Adaptation). The assembly file built by the project can be used by other PCL projects.

  • FHSDKPhone

    A WP8 library project. Contains implementaion details for WP8 platform.

  • FHXamarinAndroidSDK

    A Xamarin Android library project. Contains implementaion details for Android platform.

  • FHXamarinIOSSDK

    A Xamarin IOS library project. Contains implementaion details for iOS platform.

Testing

There are 3 test projects ceated for each platform:

  • FHSDKAndroidTest (NUnit Lite for Android)
  • FHSDKIOSTest (NUnit Lite for IOS)
  • FHSDKWindowsPhoneTestNative (WindowsPhoneUnitTest)

They all link to the test files in FHSDKTestShared project.

Before running the test, make sure the TestCloudApp is running somewhere, and update the following files to point them to the cloud app:

Then you can deploy the test projects to the emulators or devices and run the tests (For Windows Phone, just run the tests using Visual Studio).

Building

Open FHSDK.sln solution in Visual Studio and build. For Xamarin open FHSDK-xamarin-studio.sln in root folder.

Documentation

To generate and publish the API docs, please do the following:

  • Install doxygen
  • From the command prompt run doxygen .\Documentations\Doxyfile
  • Commit changes
  • Checkout gh-pages branch
  • Merge the branch which contains the latests docs
  • Push gh-pages to remote repo

Publishing to NuGet

Read the infomation in the dist folder