Azure通知中心没有';我不为ios工作
我创建了azure通知中心并将其添加到我的应用程序注册中。我的应用注册远程通知成功,当我尝试在后端注册设备时,我成功获得了安装idAzure通知中心没有';我不为ios工作,ios,azure,xamarin,push-notification,apple-push-notifications,Ios,Azure,Xamarin,Push Notification,Apple Push Notifications,我创建了azure通知中心并将其添加到我的应用程序注册中。我的应用注册远程通知成功,当我尝试在后端注册设备时,我成功获得了安装id public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { MobileServiceClient client = QSTodoService.DefaultService.GetClient; const strin
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
MobileServiceClient client = QSTodoService.DefaultService.GetClient;
const string templateBodyAPNS = "{\"aps\":{\"alert\":\"$(messageParam)\"}}";
JObject templates = new JObject();
templates["genericMessage"] = new JObject
{
{"body", templateBodyAPNS}
};
// Register for push with your mobile app
var push = client.GetPush();
push.RegisterAsync(deviceToken, templates);
}
但是当尝试发送通知时
// Get the settings for the server project.
HttpConfiguration config = this.Configuration;
MobileAppSettingsDictionary settings =
this.Configuration.GetMobileAppSettingsProvider().GetMobileAppSettings();
// Get the Notification Hubs credentials for the Mobile App.
string notificationHubName = settings.NotificationHubName;
string notificationHubConnection = settings
.Connections[MobileAppSettingsKeys.NotificationHubConnectionString].ConnectionString;
// Create a new Notification Hub client.
NotificationHubClient hub = NotificationHubClient
.CreateClientFromConnectionString(notificationHubConnection, notificationHubName);
// Sending the message so that all template registrations that contain "messageParam"
// will receive the notifications. This includes APNS, GCM, WNS, and MPNS template registrations.
Dictionary<string, string> templateParams = new Dictionary<string, string>();
templateParams["messageParam"] = "some message";
try
{
var result = hub.SendTemplateNotificationAsync(templateParams);
}
catch (System.Exception ex)
{
config.Services.GetTraceWriter()
.Error(ex.Message, null, "Push.SendAsync Error");
}
顺便说一句,notificationId为空,状态通知显示为“已排队”。我从头开始学习教程,重新创建证书,设置配置文件,通知中心等,现在它可以工作了。我从头开始学习教程,重新创建证书,设置配置文件,通知中心等,现在它可以工作了。您是否已验证您正在使用“侦听、管理、发送”连接字符串(来自Azure)进行notificationHubConnection?是的,我正在使用FullSharedAccessSignature进行连接是否确实为您的应用程序使用了正确的配置文件?如果不是,则不会收到任何内容。您是否已验证您正在使用“侦听、管理、发送”连接字符串(来自Azure)进行notificationHubConnection?是的,我正在使用FullSharedAccessSignature进行连接您真的确定您的应用程序使用了正确的配置文件?如果没有,将不会收到任何东西。
string payload = "{\"aps\":{\"alert\":\"Notification Hub test notification\"}}";
List<string> tags = new List<string> {"testTag"};
hub.CreateAppleTemplateRegistrationAsync(token,payload,tags);
Dictionary<string, string> templateParams = new Dictionary<string, string>();
templateParams["messageParam"] = "message";
var res = hub.SendTemplateNotificationAsync(templateParams, tags);
hub.SendAppleNativeNotificationAsync(payload);