Skip to content

Commit

Permalink
Merge pull request #5 from WURFL/develop
Browse files Browse the repository at this point in the history
v1.3.0.2
  • Loading branch information
mbellomi committed Dec 19, 2017
2 parents c278292 + 9fc98a7 commit 4b8efb7
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 32 deletions.
4 changes: 4 additions & 0 deletions 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

Expand Down
4 changes: 2 additions & 2 deletions Client/WurflCloud/Properties/AssemblyInfo.cs
Expand Up @@ -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]

7 changes: 5 additions & 2 deletions Client/WurflCloud/ScientiaMobile.WurflCloud.csproj
Expand Up @@ -35,18 +35,21 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>scientiamobile.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<DelaySign>false</DelaySign>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Newtonsoft.Json.dll</HintPath>
<HintPath>lib\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Web" />
Expand Down
3 changes: 1 addition & 2 deletions CloudDemo/Services/Home/WurflService.cs
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion CloudDemo/Web.config
Expand Up @@ -10,7 +10,6 @@
providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
Expand Down Expand Up @@ -77,6 +76,10 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
136 changes: 114 additions & 22 deletions README.md
Expand Up @@ -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<string, string> 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:
Expand Down Expand Up @@ -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.
Expand Down
Expand Up @@ -38,7 +38,7 @@ public void testInvalidApiKey()

foreach (KeyValuePair<string, string> pair in di.Errors)
{
if (pair.Value.Equals("No API key was provided"))
if (pair.Value.Equals("Invalid API key"))
apiKeyError = true;
}

Expand Down
6 changes: 4 additions & 2 deletions nuget_package/Wurfl_Official_Cloud_API.nuspec
Expand Up @@ -2,15 +2,17 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Wurfl_Official_Cloud_API</id>
<version>1.3.0.1</version>
<version>1.3.0.2</version>
<title>The official WURFL Cloud API for .NET</title>
<authors>ScientiaMobile,Inc.</authors>
<licenseUrl>https://github.com/WURFL/wurfl-cloud-client-dotnet/blob/master/COPYING.txt</licenseUrl>
<iconUrl>http://wurfl.sourceforge.net/logos/wurfl_logo_main_114px.gif</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>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.</description>
<releaseNotes>WURFL Cloud Client 1.3.0.1:
<releaseNotes>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:
Expand Down

0 comments on commit 4b8efb7

Please sign in to comment.