Following this tutorial Ich habe azurblauen Benachrichtigungs-Hub erstellt und meiner App-Registrierung hinzugefügt. Meine App registriert sich für die Remote-Benachrichtigung erfolgreich und als ich versucht habe, das Gerät am Backend zu registrieren, habe ich meine Installations-ID erhalten.Azure Notification Hub funktioniert nicht für iOS
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);
}
Aber wenn ich versuche, Benachrichtigung zu senden
// 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");
}
Ergebnis sagte „erfolgreich gesendet: 0, schlug fehl gesendet: 0
Was ist der Grund für diese Probleme sein kann
Update
Ich glaube nicht das Problem mit sertificate oder provisioning Profil wie wenn ich versuche, eine Benachrichtigung über azurblau zu senden - es senden. (obwohl ich nicht empfange, aber es ist schon ein anderes Problem).
Update 2
ich auch
, registriert Tag zu senden habe versuchtstring 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);
und Apfel ursprüngliche Benachrichtigung, aber Ergebnis war das gleiche.
hub.SendAppleNativeNotificationAsync(payload);
BTW, ist notificationId leer und zeigt Statusmitteilung als 'eingereihter'.
Haben Sie überprüft, dass Sie die Verbindungszeichenfolge "Listen, Manage, Send" (von Azure) für notificationHubConnection verwenden? – mpwhitt
Ja, ich verwende FullSharedAccessSignature für die Verbindung –
Sind Sie wirklich sicher, dass Sie das richtige Bereitstellungsprofil für Ihre Anwendung verwenden? Wenn nicht, wird nichts erhalten. – Cheesebaron