[英]Parse Push Notification in Objective-C
我正在尝试使用Parse.com SDK来实现iOS推送通知。 问题是,有时没有任何错误日志就不会发送推送通知。 我将代码更改为此:
- (IBAction)send:(id)sender {
PFQuery *usernameQuery = [PFUser query];
[usernameQuery whereKey:@"objectId" containedIn:self.recipients];
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:@"user" matchesQuery:usernameQuery];
PFPush *push =[[PFPush alloc] init];
[push setQuery:pushQuery];
[push setMessage:[NSString stringWithFormat:@"%@: %@", [PFUser currentUser].username, self.kwik]];
[push sendPushInBackground];
[self.navigationController popToRootViewControllerAnimated:YES];
NSLog(@"%p", push);
}
我不知道每次用户发送推送时分配PFPush还是会出现此问题。 在将代码更改为该代码之前,我正在调用self.push = [[PFPush alloc] init];
在viewDidLoad方法中,因为由于内存占用,我不希望每次用户发送“推式通知”时都分配新的PFPush。 现在我的问题是:每次用户发送推送时分配一个新的PFPush对象是否重要?或者我可以在viewDidLoad方法中分配它吗?
该行:
PFPush *push =[[PFPush alloc] init];
创建一个对象,但是对它的引用是短暂的(完成异步请求请求所花费的时间),并且在ARC项目中,将在编译时插入代码以释放它,因此无需担心内存分配。
您可能有不相关的问题,无法发送推送。 一种调试方法是在后台使用称为sendPushInBackgroundWithBlock的各种块推送 。 这样,您可以检查错误是否存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.