本文整理汇总了C#中Microsoft.WindowsAzure.MobileServices.MobileServiceClient.GetPush方法的典型用法代码示例。如果您正苦于以下问题:C# MobileServiceClient.GetPush方法的具体用法?C# MobileServiceClient.GetPush怎么用?C# MobileServiceClient.GetPush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.MobileServices.MobileServiceClient
的用法示例。
在下文中一共展示了MobileServiceClient.GetPush方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterForRemotePushNotifications
public void RegisterForRemotePushNotifications(MobileServiceClient client, string channelName)
{
// Register for push with Mobile Services
IEnumerable<string> tag = new List<string>() { channelName };
var push = client.GetPush();
push.RegisterNativeAsync(DeviceToken, tag);
}
示例2: UploadChannel
public async static void UploadChannel()
{
PushNotificationChannel channel;
try
{
channel = await PushNotificationChannelManager
.CreatePushNotificationChannelForApplicationAsync();
channel.PushNotificationReceived += channel_PushNotificationReceived;
}
catch (Exception)
{
// TODO: Do something when Push Notifications are not available?
return;
}
try
{
JObject templateBody = new JObject();
templateBody["body"] = String.Format(@"<toast>
<visual>
<binding template=""ToastText01"">
<text id=""1"">$(message)</text>
</binding>
</visual>
</toast>");
JObject wnsToastHeaders = new JObject();
wnsToastHeaders["X-WNS-Type"] = "wns/toast";
templateBody["headers"] = wnsToastHeaders;
JObject templates = new JObject();
templates["MyHealthClinicTemplate"] = templateBody;
client = new MobileServiceClient(AppSettings.MobileAPIUrl, string.Empty, string.Empty);
await client.GetPush()
.RegisterAsync(channel.Uri, templates);
// Add a new tag to get only the notification for the default patientId.
var tags = new JArray();
tags.Add(AppSettings.DefaultTenantId);
// Call the custom API '/api/updatetags/<installationid>' with the JArray of tags.
var response = await client
.InvokeApiAsync("updatetags/"
+ client.InstallationId, tags);
}
catch (Exception)
{
// Handle Exception
}
}
示例3: RegisteredForRemoteNotifications
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
DeviceToken = deviceToken.Description;
DeviceToken = DeviceToken.Trim('<', '>').Replace(" ", "");
MobileServiceClient client = new MobileServiceClient(ApplicationUrl, ApplicationKey);
string userid = NSUserDefaults.StandardUserDefaults.StringForKey("CrmUserId");
if (string.IsNullOrEmpty(userid)) return;
//Tags could be expanded to handle multiple different scenarios
IEnumerable<string> tags = new List<string>() { userid, "All Users" };
var push = client.GetPush();
push.RegisterNativeAsync(DeviceToken, tags);
}
示例4: UploadChannel
public async static void UploadChannel()
{
PushNotificationChannel channel;
try
{
channel = await PushNotificationChannelManager
.CreatePushNotificationChannelForApplicationAsync();
channel.PushNotificationReceived += channel_PushNotificationReceived;
}
catch (Exception)
{
// TODO: Do something when Push Notifications are not available?
return;
}
try
{
JObject templateBody = new JObject();
templateBody["body"] = String.Format(@"<toast>
<visual>
<binding template=""ToastText01"">
<text id=""1"">$(message)</text>
</binding>
</visual>
</toast>");
JObject wnsToastHeaders = new JObject();
wnsToastHeaders["X-WNS-Type"] = "wns/toast";
templateBody["headers"] = wnsToastHeaders;
JObject templates = new JObject();
templates["MyHealthClinicTemplate"] = templateBody;
client = new MobileServiceClient(AppSettings.MobileAPIUrl, AppSettings.MobileAPIGateway, string.Empty);
await client.GetPush()
.RegisterAsync(channel.Uri, templates);
}
catch (Exception)
{
// Handle Exception
}
}
示例5: RegisteredForRemoteNotifications
public override async void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
try
{
// Get & Modify device token
_deviceToken = deviceToken.Description;
_deviceToken = _deviceToken.Trim ('<', '>').Replace (" ", "");
// Instantiate a MobileService Client
_client = new MobileServiceClient(AppSettings.MobileAPIUrl, AppSettings.MobileAPIUrl, string.Empty);
// Register for push with your mobile app
var push = _client.GetPush();
var notificationTemplate = "{\"aps\":{\"alert\":\"$(message)\"}}";
JObject templateBody = new JObject();
templateBody["body"] = notificationTemplate;
JObject templates = new JObject();
templates["testApsTemplate"] = templateBody;
await push.RegisterAsync(_deviceToken, templates);
}
catch (Exception e)
{
Debug.WriteLine("RegisteredForRemoteNotifications -> exception -> " + e.Message);
}
}
示例6: RegisteredForRemoteNotifications
public override async void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
try
{
// Instantiate a MobileService Client
_client = new MobileServiceClient(AppSettings.MobileAPIUrl);
// Register for push with your mobile app
var push = _client.GetPush();
var notificationTemplate = "{\"aps\":{\"alert\":\"$(message)\"}}";
JObject templateBody = new JObject();
templateBody["body"] = notificationTemplate;
JObject templates = new JObject();
templates["testApsTemplate"] = templateBody;
await push.RegisterAsync(deviceToken, templates);
// Add a new tag to get only the notification for the default patientId.
var tags = new JArray();
tags.Add(AppSettings.DefaultTenantId);
await _client.InvokeApiAsync("updatetags/" + _client.InstallationId, tags);
}
catch (Exception e)
{
Debug.WriteLine("RegisteredForRemoteNotifications -> exception -> " + e.Message);
}
}
示例7: AzureNotificationHubService_iOS
public AzureNotificationHubService_iOS ()
{
_mobileServiceClient = new MobileServiceClient (Helpers.Keys.AzureMobileService_URL, Helpers.Keys.AzureMobileService_KEY);
_push = _mobileServiceClient.GetPush ();
}