使用 Objective-C 防止接收自己的消息

设置过滤器适用于你将从该特定客户端订阅的所有通道。此客户端过滤器排除将此订户的 UUID 设置为发件人的 UUID 的邮件:

NSString *expression = [NSString stringWithFormat:@"(uuid != '%@'", 
                        self.client.currentConfiguration.uuid];
[self.client setFilterExpression:expression];

发布邮件时,如果希望订阅者端客户端筛选器工作,则需要包含发件人的 UUID:

[self.client publish:@"message" toChannel:@"group-chat" 
        withMetadata:@{@"uuid": self.client.currentConfiguration.uuid} 
          completion:^(PNPublishStatus *status) {

    // Check whether request successfully completed or not.
    if (!status.isError) {    

        // Message successfully published to specified channel.
    }
    else {

        // Request processing failed. Handle message publish error. 
        // Check 'category' property to find out possible issue 
        // publish can be attempted again using: [status retry];
    }
}];

也可以看看: