【发布时间】:2016-11-15 14:05:58
【问题描述】:
我正在服务器上实现通知服务,将通知推送到 Android 和 Iphone。
我目前遇到的问题是我正在测试的 Android 设备只收到默认消息。
我的代码如下:-
主程序
string smsMessageString = "{\"default\": \"This is the default message which must be present when publishing a message to a topic. The default message will only be " +
" used if a message is not present for one of the notification platforms.\"," +
"\"APNS\": {\"aps\": {\"alert\": \"Check out these awesome deals!\",\"url\": \"www.amazon.com\"}}," +
"\"GCM\": {\"data\": {\"message\": \"Check out these awesome deals!\",\"url\": \"www.amazon.com\"}}," +
"\"ADM\": {\"data\": {\"message\": \"Check out these awesome deals!\",\"url\": \"www.amazon.com\"}}}";
var smsMessage = new SmsMessageObj
{
smsMessageSubject = "Test Message",
smsMessageBody = smsMessageString
};
snsClient.SendPush(endpointArn, smsMessage);
SendPush 如下:-
public void SendPush(string endpointArn, SmsMessageObj msg)
{
if (string.IsNullOrEmpty(endpointArn))
throw new Exception("Endpoint ARN was null");
var pushMsg = new PublishRequest
{
Message = msg.smsMessageBody,
MessageStructure = "json",
Subject = msg.smsMessageSubject,
TargetArn = endpointArn
};
_client.Publish(pushMsg);
}
我是否需要添加更多内容才能获得“正确”的 Android 通知?
我需要 app.config 中的任何内容吗?
感谢您的帮助和时间
【问题讨论】:
标签: android amazon-web-services push-notification google-cloud-messaging amazon-sns