是否有任何代码说明如何直接从代码向设备发送推送通知,知道我正在使用Amazon SNS
,以便从应用程序触发推送通知?
我已将所有设备数据添加到SNS console
(令牌..),并且无法找到解决此问题的任何明确文档。
答案 0 :(得分:2)
我找到了解决方案:
AWSSNS *publishCall = [AWSSNS defaultSNS];
AWSSNSPublishInput *message = [AWSSNSPublishInput new];
message.subject = @"My First Message";
//This is the ending point
message.targetArn = @"arn:aws:sns:eu-west-X:xxxxxxxxx:endpoint/APNS_SANDBOX/AmazonTest/aaaaaaaa-aaaa-aaaaaa-aaaaaa";
message.subject =@"hello";
message.message =self.textField.text;
// message.messageAttributes = messageDict;
//
// message.messageStructure = jsonString;
if ([self.textField.text isEqualToString:@""]) {
//nothing
}else
[publishCall publish:message completionHandler:^(AWSSNSPublishResponse * _Nullable response, NSError * _Nullable error) {
if(error) NSLog(@"%@", [error userInfo]);
if(response) NSLog(@"%@", [response description]);
}];