【发布时间】:2018-11-02 22:02:19
【问题描述】:
我在 Azure 中托管了一个 Web API。 Web API 具有 POST 方法,当使用 Postman 将字符串正文消息发布到 Web API url 时,消息在 开发 中完美地发送到移动设备。这是它的代码:
[Authorize]
[HttpPost, Route("send")]
public async Task<NotificationOutcome> Post([FromBody]string message)
{
string hubName = "hubname";
string hubNameDefaultShared = "endpointAddress";
NotificationHubClient hub = NotificationHubClient
.CreateClientFromConnectionString(hubNameDefaultShared, hubName, enableTestSend: true);
string installationId = string.Empty;
var templateParams = new Dictionary<string, string>
{
["messageParam"] = message
};
NotificationOutcome result = null;
if (string.IsNullOrWhiteSpace(installationId))
{
result = await hub.SendTemplateNotificationAsync(templateParams).ConfigureAwait(false);
}
else
{
result = await hub.SendTemplateNotificationAsync(templateParams, "$InstallationId:{" + installationId + "}").ConfigureAwait(false);
}
return result;
}
当我切换到 Production 并从商店下载应用程序时,使用 Postman 发布到上面的 Web API 时没有收到推送通知:
我已经完成的步骤:
- 移动应用和通知服务扩展的应用 ID。
- 在两者上都启用了推送通知,并在 Apple 开发者网站上为两者创建了开发 SSL 推送通知证书和生产推送通知证书。
- 在我的钥匙串中,我右键单击“Apple Push Services: MyMobileApp”(生产)并导出 p12。
- 将 p12 证书上传到 APNS 下的 Azure Notification Hub,并将 Notification Hub 从 Sandbox 切换到 Production。
- 为移动应用和通知服务扩展的开发和生产创建了供应配置文件。
- 编辑了移动应用和通知扩展服务的 Entitlement.plist 并将“aps-environment”设置为“production”
- 在 info.plist 中为每个选择了生产证书和生产配置。
- 创建 ipa 文件并上传到商店。
关于通知中心,我需要对 Web API 做些什么来将其设置为生产环境吗?这些是使用 p12 证书将通知中心设置为生产的所有步骤还是我错过了什么?
【问题讨论】:
标签: azure xamarin.ios apple-push-notifications