如何在不使用查询的情况下在Parse上发送图像?

时间:2015-07-01 00:08:59

标签: ios xcode parse-platform

有没有办法在Xcode上使用解析直接发送用户列表?我能够使用查询发送图像,但我担心搜索存储在我的类中的每个图像,将其与发送它的用户匹配,然后检索该图像将需要一段时间,我我希望它很快就能存在。

这是我目前将图像保存到数据库的方式:

PFUser *currentUser = [PFUser currentUser];
NSString * username =  currentUser.username;
NSData * imageData = UIImageJPEGRepresentation(myImageView.image, 1.0f);
PFFile * newImageFile = [PFFile fileWithName:@"image.jpeg" data:imageData];
PFObject * newImage = [PFObject objectWithClassName:@"Images"];

[newImage setObject:newImageFile forKey:@"imageFile"];
[newImage setObject:name forKey:@"username"];
[newImage setObject:object forKey:@"sendImageToFollowing"];

[newImage saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {}

1 个答案:

答案 0 :(得分:1)

将图像保存到Parse.com并在推送的有效负载中发送引用该图像的推送是可行的方法,原因有两个:

  1. 通过推送消息发送超过几kb是不可能的。它们的设计非常小,所以你必须传递一些东西。
  2. 我猜你想要保存图像:)
  3. 保存图像,从Parse获取objectId,将其作为自定义推送通知有效负载的一部分发送。您可以创建自定义词典并使用推送发送它。有关更多信息,请参阅此处:

    https://www.parse.com/docs/ios/guide#push-notifications-customizing-your-notifications

    如果你想快速获得objectId,你可以在成功时从查询中获取它:

    [newImage saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        //Get the image objectId here
        NSString *objectIdString = newImage.objectId;
    }