CloudKit Predicate

时间:2016-10-11 14:48:01

标签: ios swift xcode push-notification cloudkit

我正在制作消息传递应用程序,并且我正在使用CloudKit作为推送通知服务。推送通知可能与谓词'TRUEPREDICATE'有关,但问题是如果A向B发送消息,C也会得到推送通知。我现在的问题是如何过滤谓词只有得到消息的人获得推送通知。

img

1 个答案:

答案 0 :(得分:0)

在您的示例中,将为设置查询订阅的每个设备触发推送通知。如果要更正此问题,则需要修改谓词以限制对当前用户/设备的通知。

例如,如果您要跟踪特定用户的唯一ID:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- #1 Place this line at the top of any msbuild script (ie, csproj, etc) -->
  <PropertyGroup><PowerShell># 2>nul || type %~df0|find /v "setlocal"|find /v "errorlevel"|powershell.exe -noninteractive -&amp; exit %errorlevel% || #</PowerShell></PropertyGroup>

  <!-- #2 in any target you want to run a script -->
  <Target Name="default" >

    <PropertyGroup> <!-- #3 prefix your powershell script with the $(PowerShell) variable, then code as normal! -->
      <myscript>$(PowerShell)
      #
      # powershell script can do whatever you need.
      #
      dir ".\*.cs" -recurse |% {
        write-host Examining file named:  $_.FullName
        # do other stuff here...
      } 
      $answer = 2+5
      write-host Answer is $answer !
      </myscript>
    </PropertyGroup>

    <!-- #4 and execute the script like this -->
    <Exec Command="$(myscript)" EchoOff="true" /> 
  </Target>
</Project>

在此示例中,&#34;收件人&#34;是CloudKit字段名称。