diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3d03bf7..cd7bfdb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,7 @@ +v1.3.0.2 +- FIX: CloudDemo project "Conflicting versions of ASP.NET" exception +- FIX: CloudDemo project detection error when using "By user-agent" tab + v1.3.0.1 - FIX: syntax not backward compatible with VS2013 diff --git a/Client/WurflCloud/Properties/AssemblyInfo.cs b/Client/WurflCloud/Properties/AssemblyInfo.cs index 4712a5e..93e9952 100644 --- a/Client/WurflCloud/Properties/AssemblyInfo.cs +++ b/Client/WurflCloud/Properties/AssemblyInfo.cs @@ -45,7 +45,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.0.1")] -[assembly: AssemblyFileVersion("1.3.0.1")] +[assembly: AssemblyVersion("1.3.0.2")] +[assembly: AssemblyFileVersion("1.3.0.2")] [assembly: AllowPartiallyTrustedCallers] diff --git a/Client/WurflCloud/ScientiaMobile.WurflCloud.csproj b/Client/WurflCloud/ScientiaMobile.WurflCloud.csproj index 7727df0..bdf3309 100644 --- a/Client/WurflCloud/ScientiaMobile.WurflCloud.csproj +++ b/Client/WurflCloud/ScientiaMobile.WurflCloud.csproj @@ -35,7 +35,7 @@ false - false + true scientiamobile.snk @@ -43,10 +43,13 @@ OnBuildSuccess + + false + False - lib\Newtonsoft.Json.dll + lib\Newtonsoft.Json.dll diff --git a/CloudDemo/Services/Home/WurflService.cs b/CloudDemo/Services/Home/WurflService.cs index e305e84..696ad6f 100644 --- a/CloudDemo/Services/Home/WurflService.cs +++ b/CloudDemo/Services/Home/WurflService.cs @@ -44,10 +44,9 @@ public DeviceInfoViewModel GetDataByAgent(HttpContextBase context, String ua) }; var manager = new CloudClientManager(config).SetCache(new MemoryWurflCloudCache()); - var wurflRequest = new WurflCloudRequest(context) {UserAgent = ua}; // Grab data - var info = manager.GetDeviceInfo(wurflRequest, new[] { "is_wireless_device", "is_smartphone", "physical_screen_width" }); + var info = manager.GetDeviceInfo(ua, new[] { "is_wireless_device", "is_smartphone", "physical_screen_width" }); var model = new DeviceInfoViewModel { DeviceId = info.Id, diff --git a/CloudDemo/Web.config b/CloudDemo/Web.config index b5b0857..6f98ddb 100644 --- a/CloudDemo/Web.config +++ b/CloudDemo/Web.config @@ -10,7 +10,6 @@ providerName="System.Data.SqlClient"/> - @@ -77,6 +76,10 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md index 366e475..76c4544 100644 --- a/README.md +++ b/README.md @@ -22,55 +22,147 @@ for a free or paid WURFL Cloud account (see above). When you've finished creating your account, you must copy your API Key, as it will be needed in the Client. -### Install [WURFL Cloud Client NuGet Package](https://www.nuget.org/packages/Wurfl_Official_Cloud_API/) +### Get ScientiaMobile WURFL Cloud Client assembly +You can get ScientiaMobile WURFL Cloud Client assembly in two ways: +- by cloning this Github repo and building the *ScientiaMobile.WurflCloud* project from the *master* branch +- by installing it as a [NuGet package] (https://www.nuget.org/packages/Wurfl_Official_Cloud_API/) -## Integration +In both cases you need to reference in your project the *ScientiaMobile.WurflCloud.dll* assembly along with +the third party *Newtonsoft.Json.dll* + +## Integration examples + +### Simple Console application +Here's a quick example of how to get WurflCloud up and running in a Console Application. + +In your Console Application project, add *ScientiaMobile.WurflCloud.dll* *Newtonsoft.Json.dll* assemblies as reference. + +Add a new class to named *SimpleConsoleApplication* to your project with the following code. + +```c# +using System; +using System.Collections.Generic; +using ScientiaMobile.WurflCloud; +using ScientiaMobile.WurflCloud.Config; +using ScientiaMobile.WurflCloud.Cache; +using ScientiaMobile.WurflCloud.Device; + +namespace YourNameSpace +{ + class SimpleConsoleApplication + { + static void Main(string[] args) + { + // The User-Agent to detect + var ua = "Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.466 Mobile Safari/534.8+"; + + // The WurflCloud configuration + var config = new DefaultCloudClientConfig + { + // Your API Key + ApiKey = "xxxxxx:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" + }; + + // Configure CloudClientManager with no cache + var cache = new NoWurflCloudCache(); + + var manager = new CloudClientManager(config, cache); + + // Get all static capability provided by your license + var capabilities = new string[0]; + + // Perform device detection using provided User-Agent + DeviceInfo di = manager.GetDeviceInfo(ua, capabilities); + + // Write the detected Device Id + Console.WriteLine(di.Id); + + // Write static capabilities name/value + foreach (KeyValuePair entry in di.Capabilities) + { + Console.WriteLine(entry.Key + " " + entry.Value); + } + + Console.ReadKey(); + } + } +} +``` + +### Simple Web application You should review the included example (CloudDemo) to get a feel for -the Client API, and how best to use it in your application. +the Client API, and how best to use it in your web application. Here's a quick example of how to get up and running quickly: +In CloudDemo\Services\Home\WurflService.cs set your personal ApiKey +both in GetDataByRequest and GetDataByAgent methods. + +GetDataByRequest is an example on how to get capabilities starting from the HttpRequest. + ```c# public DeviceInfoViewModel GetDataByRequest(HttpContext context) { var config = new DefaultCloudClientConfig { - ApiKey = "123456:xxxxxxxxxxxxxxxxxxxxxxxxxx" + ApiKey = "xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }; var manager = new CloudClientManager(config); var info = manager.GetDeviceInfo(context, new[] { "is_wireless_device", "model_name" }); var model = new DeviceInfoViewModel { - DeviceId = info.Id, - ServerVersion = info.ServerVersion, - DateOfRequest = info.WurflLastUpdate.ToString(), - Library = manager.GetClientVersion(), - Capabilities = info.Capabilities, - Errors = info.Errors, - Source = info.ResponseOrigin + DeviceId = info.Id, + ServerVersion = info.ServerVersion, + DateOfRequest = info.WurflLastUpdate.ToString(), + Library = manager.GetClientVersion(), + Capabilities = info.Capabilities, + Errors = info.Errors, + Source = info.ResponseOrigin }; return model; } ``` -The `CloudDemo\ViewModels\DeviceInfoViewModel` is a helper class that -gathers information from the WURFL cloud client API and makes it ready -for display. You can directly check a capability as below: +GetDataByAgent is an example on how to get capabilities starting from a User-Agent string ```c# -var isMobileAsText = info.Get("is_wireless_device"); // Returns a string! +public DeviceInfoViewModel GetDataByAgent(HttpContextBase context, String ua) +{ + var config = new DefaultCloudClientConfig + { + ApiKey = "xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + }; + + var manager = new CloudClientManager(config).SetCache(new MemoryWurflCloudCache()); + + // Grab data + var info = manager.GetDeviceInfo(ua, new[] { "is_wireless_device", "is_smartphone", "physical_screen_width" }); + var model = new DeviceInfoViewModel + { + DeviceId = info.Id, + UserAgent = ua, + ServerVersion = info.ServerVersion, + DateOfRequest = info.WurflLastUpdate.ToLongTimeString(), + Library = manager.GetClientVersion(), + Capabilities = info.Capabilities, + Errors = info.Errors, + Source = info.ResponseOrigin + }; + return model; +} ``` -If you want to test capabilities starting from a user agent string, you proceed as follows: +The `CloudDemo\ViewModels\DeviceInfoViewModel` is a helper class that +gathers information from the WURFL cloud client API and makes it ready +for display. + +You can directly check a capability as below: ```c# -var ua = "apple iphone"; -var manager = new CloudClientManager(config); -var wurflRequest = new WurflCloudRequest(context) {UserAgent = ua}; -var info = manager.GetDeviceInfo(context, new[] { "is_wireless_device", "model_name" }); +var isMobileAsText = info.Get("is_wireless_device"); // Returns a string! ``` -# Configuration +## Configuration --------------- The public interface of the WURFL Cloud API is fairly simple and consists of a single class, `Client\WurflCloud\CloudClientManager`. The members of this class are: @@ -131,7 +223,7 @@ Caching modules available: entry. By invalidating the helper cache entry, you can clear all cached data in a single shot. -# Querying the Cloud Client API +## Querying the Cloud Client API -------------- To query the WURFL database in the cloud, you use the GetDeviceInfo method on the `Client\WurflCloud\CloudClientManager` class. diff --git a/ScientiaMobile.WurflCloudTest-NUnit/CloudClientInvalidApiKeyTest.cs b/ScientiaMobile.WurflCloudTest-NUnit/CloudClientInvalidApiKeyTest.cs index ad24935..594f2fe 100644 --- a/ScientiaMobile.WurflCloudTest-NUnit/CloudClientInvalidApiKeyTest.cs +++ b/ScientiaMobile.WurflCloudTest-NUnit/CloudClientInvalidApiKeyTest.cs @@ -38,7 +38,7 @@ public void testInvalidApiKey() foreach (KeyValuePair pair in di.Errors) { - if (pair.Value.Equals("No API key was provided")) + if (pair.Value.Equals("Invalid API key")) apiKeyError = true; } diff --git a/nuget_package/Wurfl_Official_Cloud_API.nuspec b/nuget_package/Wurfl_Official_Cloud_API.nuspec index 5c102f9..c3dfbfb 100644 --- a/nuget_package/Wurfl_Official_Cloud_API.nuspec +++ b/nuget_package/Wurfl_Official_Cloud_API.nuspec @@ -2,7 +2,7 @@ Wurfl_Official_Cloud_API - 1.3.0.1 + 1.3.0.2 The official WURFL Cloud API for .NET ScientiaMobile,Inc. https://github.com/WURFL/wurfl-cloud-client-dotnet/blob/master/COPYING.txt @@ -10,7 +10,9 @@ true The official ASP.NET WURFL Cloud API allows you to query the WURFL database without having to host the database in your applications. This is beneficial because it guarantees that your WURFL data are always up to date. In addition, you don’t need to be concerned about distributing and synchronizing your WURFL data around the world: the WURFL cloud does it for you. - WURFL Cloud Client 1.3.0.1: + WURFL Cloud Client 1.3.0.2: +v1.3.0.2: +- FIX: Strong-Named assembly v1.3.0.1: - FIX: syntax not backward compatible with VS2013 v1.3.0.0: