【发布时间】:2015-12-11 08:30:19
【问题描述】:
我正在使用 Azure 通知中心发送通知。我希望这些通知是多语言的,但我找不到
NSString* jsontemplate= [NSString stringWithFormat:@"{\"aps\":
{\"alert\":\"$(News_%@)\"},\"inAppMessage\":\"$(News_%@)\"}",
localeString, localeString];
在函数中使用
Hub.RegisterTemplateAsync(deviceToken,name,jsontemplate,expirytemplate,tags,
(errorCallback) => {
if (errorCallback != null)
Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); });
这将替换下面代码 sn-p 中的 Hub.RegisterNativeAsync 函数,我现在拥有它,它适用于简单的通知。
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
Hub = new SBNotificationHub(TnOConstants.AzureListenConnectionString, TnOConstants.AzureNotificationHubName);
Hub.UnregisterAllAsync (deviceToken, (error) => {
if (error != null)
{
Console.WriteLine("Error calling Unregister: {0}", error.ToString());
return;
}
string[] tag = new string[]{"tnoios", "ios-"+ appVersion.ToString()};
NSSet tags = new NSSet(tag);
Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => {
if (errorCallback != null)
Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());
});
});
}
【问题讨论】:
-
如果您使用的是 C#,则等价于
string.Format("{0}{1}", firstArg, secondArg);
标签: objective-c azure push-notification xamarin.ios azure-notificationhub