CloudKit订阅无效

时间:2016-02-17 11:10:46

标签: ios swift cloudkit

我尝试使用Swift使用CloudKit订阅推送通知。这是我的代码:

应用代表:

func addNewRecordsSub() {
    let subscription = CKSubscription(recordType: "UserRecords", predicate: predicate, options: .FiresOnRecordCreation)
    let notificationInfo = CKNotificationInfo()
    notificationInfo.alertBody = "OK!"
    notificationInfo.shouldBadge = true
    subscription.notificationInfo = notificationInfo
    let privateDatabase = container.privateCloudDatabase
    privateDatabase.saveSubscription(subscription) { subscription, error in
        if error != nil {
            print(error)
        }

    }
}

创作:

$m_curl  = curl_multi_init();

// Firstly I create CURL handles
for ($i = 0; $i < count($params); ++$i) {
    $params[$i]['curl'] = curl_init();
    curl_setopt($params[$i]['curl'], CURLOPT_HEADER, 1);
    curl_setopt($params[$i]['curl'], CURLOPT_VERBOSE, 1);
    curl_setopt($params[$i]['curl'], CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($params[$i]['curl'], CURLOPT_URL, $params[$i]['url']);
    curl_multi_add_handle($m_curl, $params[$i]['curl']);
}

// Now we do the multicurl thing
$active = null;
do {
    $status = curl_multi_exec($m_curl, $active);
    if ($status > 0) die ('ERROR!'); // This is not stopping script, so I suppose that we got no errors in requests
} while ($status == CURLM_CALL_MULTI_PERFORM);

// Organize response
for ($i = 0; $i < count($params); ++$i) {
    $results[$i] = ['results' => []];

    foreach ($params[$i]['curl'] as $curl) {
        $result        = curl_multi_getcontent($curl);
        $header_size   = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
        $result_header = substr($result, 0, $header_size);
        $result_body   = substr($result, $header_size);

        // We got wrong result - response is NULL
        if ($result == NULL) {
           echo 'empty response!'; // and there should be something
        }
        else {
           // it's OK, co we do stuff there
           // ...
           curl_multi_remove_handle($m_curl, $curl);
        }
    }
}

// Close multicurl
curl_multi_close($m_curl);

发布后,订阅已显示在CloudKit的信息中心中:

enter image description here

但是当我添加新唱片时没有任何反应......什么都没有。我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

我试图再次重置环境,现在一切正常......