Updates with UserID (#10)
* Updating to include UserID * Updating Android * Update to add user ID * Updating to 1.1.1
This commit is contained in:
Родитель
e9fa59b9a2
Коммит
301562f6b4
36
README.md
36
README.md
|
@ -98,6 +98,18 @@ template.Tags = new List<string> { languageTag, countryCodeTag };
|
|||
NotificationHub.SetTemplate("template1", template);
|
||||
```
|
||||
|
||||
### Push to User Management
|
||||
|
||||
The SDK supports the ability to associate a user with an installation. This allows you to be able to target all devices associated with a particular User ID. The user's identity set through the SDK can be whatever the developer wants it to be: the user's name, email address, phone number, or some other unique identifier. This is supported through the `NotificationHub` and the `UserId` property.
|
||||
|
||||
```csharp
|
||||
var userId = "iosUser123"
|
||||
NotificationHub.UserId = userId;
|
||||
|
||||
// Get the user ID
|
||||
Console.WriteLine($"User ID: {NotificationHub.UserId}");
|
||||
```
|
||||
|
||||
### Enriching Installations
|
||||
|
||||
The SDK will update the installation on the device any time you change its properties such as adding a tag or adding an installation template. Before the installation is sent to the backend, you can intercept this installation to modify anything before it goes to the backend, for example, if you wish to add or modify tags. This is implemented in the `IInstallationEnrichmentAdapter` interface with a single method of `EnrichInstallation`.
|
||||
|
@ -214,6 +226,18 @@ template.AddTag(countryCodeTag);
|
|||
MSNotificationHub.SetTemplate(template, key: "template1");
|
||||
```
|
||||
|
||||
### Push to User Management
|
||||
|
||||
The SDK supports the ability to associate a user with an installation. This allows you to be able to target all devices associated with a particular User ID. The user's identity set through the SDK can be whatever the developer wants it to be: the user's name, email address, phone number, or some other unique identifier. This is supported through the `MSNotificationHub` and the `GetUserId` and `SetUserId` methods.
|
||||
|
||||
```csharp
|
||||
var userId = "iosUser123"
|
||||
MSNotificationHub.SetUserId(userId);
|
||||
|
||||
// Get the user ID
|
||||
Console.WriteLine($"User ID: {NotificationHub.GetUserId()}");
|
||||
```
|
||||
|
||||
### Intercepting Installation Management
|
||||
|
||||
The SDK will handle saving the installation for you, however, we provide hooks where you can intercept both the successful installation or any failure through the `MSInstallationLifecycleDelegate` abstract class. This has two methods, `DidSaveInstallation` for successful saves, and `DidFailToSaveInstallation` for any failures. We can implement this to have our own logging for example.
|
||||
|
@ -411,6 +435,18 @@ template.AddTags(new[] { languageTag, countryCodeTag });
|
|||
NotificationHub.SetTemplate("template1", template);
|
||||
```
|
||||
|
||||
### Push to User Management
|
||||
|
||||
The SDK supports the ability to associate a user with an installation. This allows you to be able to target all devices associated with a particular User ID. The user's identity set through the SDK can be whatever the developer wants it to be: the user's name, email address, phone number, or some other unique identifier. This is supported through the `NotificationHub` and the `GetUserId` and `SetUserId` methods.
|
||||
|
||||
```csharp
|
||||
var userId = "iosUser123"
|
||||
NotificationHub.SetUserId(userId);
|
||||
|
||||
// Get the user ID
|
||||
Console.WriteLine($"User ID: {NotificationHub.UserId}");
|
||||
```
|
||||
|
||||
### Intercepting Installation Management
|
||||
|
||||
The SDK will handle saving the installation for you, however, we provide hooks where you can intercept both the successful installation or any failure through the `IInstallationAdapterListener` interface for successful saves and the `IInstallationAdapterErrorListener` interface for any errors.
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1269" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
|
||||
<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="71.1610.4" />
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainActivity.cs" />
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace NHubSampleXamarinAndroid
|
|||
NotificationHub.SetInstallationSaveFailureListener(new InstallationSaveFailedListener());
|
||||
|
||||
// Initialize with hub name and connection string
|
||||
NotificationHub.Initialize(Application, hubName, connectionString);
|
||||
NotificationHub.Start(Application, hubName, connectionString);
|
||||
|
||||
// Add a tag
|
||||
NotificationHub.AddTag("target_XamarinAndroid");
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
<PackageReference Include="Xamarin.Android.Support.Media.Compat" Version="28.0.0.3" />
|
||||
<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="117.2.1-preview02" />
|
||||
<PackageReference Include="Xamarin.Android.Volley" Version="1.1.1.1" />
|
||||
<PackageReference Include="Xamarin.Azure.NotificationHubs.Android" Version="1.1.0" />
|
||||
<PackageReference Include="Xamarin.Azure.NotificationHubs.Android" Version="1.1.1" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -23,6 +23,11 @@ namespace Microsoft.Azure.NotificationHubs.Client
|
|||
/// </summary>
|
||||
public DateTime? ExpirationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user ID for the installation.
|
||||
/// </summary>
|
||||
public string UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The tags for the installation.
|
||||
/// </summary>
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.iOS')) OR $(TargetFramework.StartsWith('Xamarin.TVOS')) OR $(TargetFramework.StartsWith('Xamarin.Mac')) ">
|
||||
<!-- Add Xamarin iOS bindings -->
|
||||
<PackageReference Include="Xamarin.Azure.NotificationHubs.iOS" Version="3.0.2" />
|
||||
<PackageReference Include="Xamarin.Azure.NotificationHubs.iOS" Version="3.1.0" />
|
||||
|
||||
<!-- iOS files have ios.cs -->
|
||||
<Compile Include="**\*.ios.cs" />
|
||||
|
@ -52,7 +52,8 @@
|
|||
|
||||
<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
|
||||
<!-- Add Xamarin Android bindings -->
|
||||
<PackageReference Include="Xamarin.Azure.NotificationHubs.Android" Version="1.0.1" />
|
||||
<PackageReference Include="Xamarin.Azure.NotificationHubs.Android" Version="1.1.1" />
|
||||
<PackageReference Include="Xamarin.Android.Volley" Version="1.1.1.1" />
|
||||
<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="71.1610.4" />
|
||||
<PackageReference Include="Xamarin.Firebase.Messaging" Version="71.1740.4" />
|
||||
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.3" />
|
||||
|
|
|
@ -100,6 +100,9 @@ namespace Microsoft.Azure.NotificationHubs.Client
|
|||
|
||||
static void PlatformSetEnricher() => AndroidNotificationHub.UseVisitor(_installationEnrichmentVisitor);
|
||||
|
||||
static string PlatformGetUserId() => AndroidNotificationHub.UserId;
|
||||
static void PlatformSetUserId(string value) => AndroidNotificationHub.SetUserId(value);
|
||||
|
||||
#region Tags
|
||||
|
||||
static bool PlatformAddTag(string tag) => AndroidNotificationHub.AddTag(tag);
|
||||
|
|
|
@ -102,6 +102,9 @@ namespace Microsoft.Azure.NotificationHubs.Client
|
|||
MSNotificationHub.SetEnrichmentDelegate(_installationEnrichmentDelegate);
|
||||
}
|
||||
|
||||
static string PlatformGetUserId() => MSNotificationHub.GetUserId();
|
||||
static void PlatformSetUserId(string value) => MSNotificationHub.SetUserId(value);
|
||||
|
||||
#region iOS Initialization
|
||||
|
||||
public static void RegisteredForRemoteNotifications(NSData deviceToken) => MSNotificationHub.DidRegisterForRemoteNotifications(deviceToken);
|
||||
|
|
|
@ -10,6 +10,9 @@ namespace Microsoft.Azure.NotificationHubs.Client
|
|||
static void PlatformInitialize(IInstallationManagementAdapter installationManagementAdapter) => throw new NotImplementedException();
|
||||
static void PlatformSetEnricher() => throw new NotImplementedException();
|
||||
|
||||
static string PlatformGetUserId() => throw new NotImplementedException();
|
||||
static void PlatformSetUserId(string value) => throw new NotImplementedException();
|
||||
|
||||
#region Tags
|
||||
|
||||
static bool PlatformAddTag(string tag) => default;
|
||||
|
|
|
@ -7,6 +7,15 @@ namespace Microsoft.Azure.NotificationHubs.Client
|
|||
/// </summary>
|
||||
public partial class NotificationHub
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or set the user ID.
|
||||
/// </summary>
|
||||
public static string UserId
|
||||
{
|
||||
get => PlatformGetUserId();
|
||||
set => PlatformSetUserId(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the platform specific push channel
|
||||
/// </summary>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<PackageProjectUrl>https://go.microsoft.com/fwlink/?linkid=864958</PackageProjectUrl>
|
||||
<PackageLicenseUrl>https://go.microsoft.com/fwlink/?linkid=864960</PackageLicenseUrl>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageVersion>1.0.1</PackageVersion>
|
||||
<PackageVersion>1.1.1</PackageVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,8 +4,8 @@ var IOS_VERSION = "3.1.0";
|
|||
var IOS_NUGET_VERSION = "3.1.0";
|
||||
var IOS_URL = $"https://github.com/Azure/azure-notificationhubs-ios/releases/download/{IOS_VERSION}/WindowsAzureMessaging-SDK-Apple-{IOS_VERSION}.zip";
|
||||
|
||||
var ANDROID_VERSION = "1.1.0";
|
||||
var ANDROID_NUGET_VERSION = "1.1.0";
|
||||
var ANDROID_VERSION = "1.1.1";
|
||||
var ANDROID_NUGET_VERSION = "1.1.1";
|
||||
var ANDROID_URL = string.Format ("https://dl.bintray.com/microsoftazuremobile/SDK/com/microsoft/azure/notification-hubs-android-sdk/{0}/notification-hubs-android-sdk-{0}.aar", ANDROID_VERSION);
|
||||
|
||||
Task("libs-ios")
|
||||
|
|
Загрузка…
Ссылка в новой задаче