Matchmore.SDK 0.7.9

dotnet add package Matchmore.SDK --version 0.7.9
NuGet\Install-Package Matchmore.SDK -Version 0.7.9
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Matchmore.SDK" Version="0.7.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Matchmore.SDK --version 0.7.9
#r "nuget: Matchmore.SDK, 0.7.9"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Matchmore.SDK as a Cake Addin
#addin nuget:?package=Matchmore.SDK&version=0.7.9

// Install Matchmore.SDK as a Cake Tool
#tool nuget:?package=Matchmore.SDK&version=0.7.9

Matchmore .NET SDK

Matchmore is a contextualized publish/subscribe model which can be used to model any geolocated or proximity based mobile applications. Save time and make development easier by using our SDK.

Installation

You can install the SDK directly from Nuget for .NET Standard https://www.nuget.org/packages/Matchmore.SDK/

Or https://www.nuget.org/packages/Matchmore.SDK.Xamarin/ for xamarin builds For Xamarin we come with some defaults for your application and accessing location services and persisting state.

Usage

Setup application API key and world, get it for free from http://matchmore.io/.

async Task SetupMatchmore()
{
    await Matchmore.SDK.Matchmore.ConfigureAsync("YOUR_API_KEY");
}

If you are using the sdk in a server application or similar, please refer to the customization section

Create first device, publication and subscription. Please note that we're not caring about errors right now.

//call this before you can operate on default operations
await Matchmore.SDK.Matchmore.Instance.SetupMainDeviceAsync();

//this will only work if you are using the xamarin package or provide your own custom ILocationService
Matchmore.SDK.Matchmore.Instance.StartLocationService();

//you can access the device later by calling Matchmore.SDK.Matchmore.Instance.MainDevice
var sub = new Subscription
        {
            Topic = "Test Topic",
            Duration = 30,
            Range = 100,
            Selector = "test = true and price <= 200"
        };

var createdPub = await Matchmore.SDK.Matchmore.Instance.CreateSubscriptionAsync(sub);

var pubDevice = await Matchmore.SDK.Matchmore.Instance.CreateDeviceAsync(new MobileDevice
            {
                Name = "Publisher"
            });

var pub = new Publication
		{
			Topic = "Test Topic",
			Duration = 30,
			Range = 100,
			Properties = new Dictionary<string, object>(){
				{"test", true},
				{"price", 199}
			}
		};
//you can pass explicitly the device you would want to use
var createdPub = await Matchmore.SDK.Matchmore.Instance.CreatePublicationAsync(pub, pubDevice);

To receive matches, you need to create a monitor

//default params of .SubscribeMatches() use your main device and Polling as a channel delivery mechanism
var monitor = Matchmore.SDK.Matchmore.Instance.SubscribeMatches();
monitor.MatchReceived += (object sender, MatchReceivedEventArgs e) => {
    //handle your match
};

//if  you don't have access to your monitor, you can attach the event handler on the Matchmore Instance
Matchmore.SDK.Matchmore.Instance.MatchReceived += (object sender, MatchReceivedEventArgs e) => {
    //handle your match, the sender will be your monitor
};

Third party match providers(APNS and FCM)

To use your match provider of your choice, you need to wire it differently depending on the platform.

First you need to provide the token for the platform(FCM or APNS) to Matchmore so we know where to route the match id

//fcm
Matchmore.SDK.Matchmore.Instance.UpdateDeviceCommunicationAsync(new Matchmore.SDK.Communication.FCMTokenUpdate("token taken from FCM"));
//basing of https://docs.microsoft.com/en-us/xamarin/android/data-cloud/google-messaging/remote-notifications-with-fcm?tabs=vswin

[Service]
[IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
public class MyFirebaseIIDService : FirebaseInstanceIdService
{
    const string TAG = "MyFirebaseIIDService";
    public override void OnTokenRefresh()
    {
        var refreshedToken = FirebaseInstanceId.Instance.Token;
        Log.Debug(TAG, "Refreshed token: " + refreshedToken);
        Matchmore.SDK.Matchmore.Instance.UpdateDeviceCommunicationAsync(new Matchmore.SDK.Communication.FCMTokenUpdate(refreshedToken));
    }
}

//apns
Matchmore.SDK.Matchmore.Instance.UpdateDeviceCommunicationAsync(new Matchmore.SDK.Communication.APNSTokenUpdate("token taken from APNS"));
//basing of https://github.com/xamarin/ios-samples/blob/master/Notifications/AppDelegate.cs
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
	Matchmore.SDK.Matchmore.Instance.UpdateDeviceCommunicationAsync(new Matchmore.SDK.Communication.APNSTokenUpdate(deviceToken.ToString()));
}

Then you need to tell Matchmore whenever you will get a match id to retrieve.

//android fcm
[Service]
[IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
public class MyFirebaseMessagingService : FirebaseMessagingService
{

    IMatchProviderMonitor matchProviderMonitor = Matchmore.SDK.Matchmore.Instance.SubscribeMatchesWithThirdParty();
    const string TAG = "MyFirebaseMsgService";
    public override void OnMessageReceived(RemoteMessage message)
    {
        matchProviderMonitor.ProvideMatchIdAsync(MatchId.Make(message.GetNotification().Body));
    }
}

//ios apns in your AppDelegate
public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo)
{
    IMatchProviderMonitor matchProviderMonitor = Matchmore.SDK.Matchmore.Instance.SubscribeMatchesWithThirdParty();
    var matchId = userInfo["matchId"].ToString();
    matchProviderMonitor.ProvideMatchIdAsync(MatchId.Make(matchId));
}

Customization

The shown ConfigureAsync method is a shorthand, you can pass config object contain more information, like implementations for location services, state repositories

await Matchmore.SDK.Matchmore.ConfigureAsync(new GenericConfig {
                ApiKey = "YOUR_API_KEY",
                LocationService = myLocationService, //implements ILocationService
                StateManager = myStateManager, // implements IStateRepository
            });

Additional info you might find useful how to setup APNS. fcm in xamarin apns in xamarin

Documentation

See the http://matchmore.io/documentation/api or consult our website for further information http://matchmore.io/

Development

To run tests for .NET Standard use dotnet command line utility

dotnet test Matchmore.SDK.NetStandard.Tests/Matchmore.SDK.NetStandard.Tests.csproj

Other devices can be run from visual studio

Authors

  • @lmlynik, lukasz.mlynik@matchmore.com

License

Matchmore is available under the MIT license. See the LICENSE file for more info.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.7.9 981 6/13/2018
0.7.7 973 6/7/2018
0.7.6 941 6/4/2018
0.7.5 1,056 5/31/2018
0.7.0 1,045 5/31/2018