私は「テクスチャ・アプリ」と呼ぶことができます。クラウド・キットを使用しています。クラウド・キットで動作する通知を追加するためにどこからでも探しています...誰かが私にコードを教えてくれますか?私は非常に失われているので、クラウドキットのプッシュ通知を詳細に追加する...また、別の "テクスチャルーム"に行く通知をwan'tしないでください(クラウドキットではレコードタイプになります...) 「テキスト2」と呼ばれるもう1つのテキストとは、「テキスト2」を使用する人に「テキスト」からの通知を送信したくないということです。エルキャプテン& Xcodeのスイフト2.0を使用してスウィフト2とクラウドキットでの通知
答えて
7.2.1
イーリア、あなたはあなたのアプリケーションのデリゲートにこれを追加する必要があります。これはデータのuserInfoパケットに到着します。データのパケットを解析して、送信されたデータベース/アプリを確認できます。あなたが始めるでしょう。この方法
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
let notification = CKQueryNotification(fromRemoteNotificationDictionary: userInfo as! [String : NSObject])
let container = CKContainer(identifier: "iCloud.com")
let publicDB = container.publicCloudDatabase
if notification.notificationType == .Query {
let queryNotification = notification as! CKQueryNotification
if queryNotification.queryNotificationReason == .RecordUpdated {
print("queryNotification.recordID \(queryNotification.recordID)")
// Your notification
}
}
print("userInfo \(userInfo["ck"])")
NSNotificationCenter.defaultCenter().postNotificationName("NotificationIdentifier", object: self, userInfo:dataDict)
}
}
}
}
}
より
UIApplicationDelegate to the class
application.registerForRemoteNotifications() to the
func application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
。
この方法を使用すると、開発中にダッシュボードを使用することができますが、プログラムによるサブスクリプションの確認ができます。
func fetchSubsInPlace() {
let container = CKContainer(identifier: "iCloud.com")
let publicDB = container.publicCloudDatabase
publicDB.fetchAllSubscriptionsWithCompletionHandler({subscriptions, error in
for subscriptionObject in subscriptions! {
let subscription: CKSubscription = subscriptionObject as CKSubscription
print("subscription \(subscription)")
}
})
}
最後にそれを取得したとき。このルーチンを使用して、アプリがスリープしている間に見逃したサブスクリプションを確実に取得し、サブスクリプションを処理した後ですべてのデバイスにアクセスしないようにすることができます。
func fetchNotificationChanges() {
let operation = CKFetchNotificationChangesOperation(previousServerChangeToken: nil)
var notificationIDsToMarkRead = [CKNotificationID]()
operation.notificationChangedBlock = { (notification: CKNotification) -> Void in
// Process each notification received
if notification.notificationType == .Query {
let queryNotification = notification as! CKQueryNotification
let reason = queryNotification.queryNotificationReason
let recordID = queryNotification.recordID
print("reason \(reason)")
print("recordID \(recordID)")
// Do your process here depending on the reason of the change
// Add the notification id to the array of processed notifications to mark them as read
notificationIDsToMarkRead.append(queryNotification.notificationID!)
}
}
operation.fetchNotificationChangesCompletionBlock = { (serverChangeToken: CKServerChangeToken?, operationError: NSError?) -> Void in
guard operationError == nil else {
// Handle the error here
return
}
// Mark the notifications as read to avoid processing them again
let markOperation = CKMarkNotificationsReadOperation(notificationIDsToMarkRead: notificationIDsToMarkRead)
markOperation.markNotificationsReadCompletionBlock = { (notificationIDsMarkedRead: [CKNotificationID]?, operationError: NSError?) -> Void in
guard operationError == nil else {
// Handle the error here
return
}
}
let operationQueue = NSOperationQueue()
operationQueue.addOperation(markOperation)
}
let operationQueue = NSOperationQueue()
operationQueue.addOperation(operation)
}
}
お手数をおかけしていただきありがとうございます。よろしくお願いします。Elia –
私のアプリが決してアクセスしなかったすべての通知をフェッチすることは本当に可能ですか?本当に?私はそれをテストする必要があります。もしそうなら、アップルの「クラウドキット」は本当に素晴らしいです;) –
はい、私はそう信じています。 – user3069232
- 1. スウィフト通知が機能しない
- 2. 2カレンダーショー1通知
- 3. サイレントプッシュ通知とノーマルプッシュ通知
- 4. ローカル通知とプッシュ通知のRx_Swift
- 5. スウィフト2に
- 6. スウィフト2 iOS9テキストケースチェック
- 7. スウィフト2:一度
- 8. スウィフト2の使用#
- 9. マージ2人の通知のオブザーバーはRxSwift
- 10. スウィフト複数のローカル通知最初のemelentのみを呼び出す
- 11. はスウィフト2:配列
- 12. は、私は以下の通り私のアプリケーションで3テキストフィールド持っスウィフト2
- 13. スウィフト2のOAuth2 LinkedInのコネクション
- 14. スウィフト2:唯一のフルスクリーンビデオ
- 15. コレクションビューコントローラ内で2つのビューをスウィフト
- 16. 数値通知アイコンWindowsフォーム1..2..3
- 17. 通知が通知されたときに通知を受け取る方法
- 18. Openfireとプッシュ通知
- 19. 通知センターとUIActionSheet
- 20. ejabberdとプッシュ通知
- 21. ローカル通知とストーリーボード
- 22. Androidでの通知
- 23. webView.loadDataWithBaseURL()で通知
- 24. DjangoとSocket.ioのリアルタイム通知
- 25. ウェブアプリケーションとモバイルアプリケーションのプッシュ通知
- 26. オリエンテーションの変更と通知
- 27. androidのアラームマネージャーと通知
- 28. Javaのスケジュール通知メール通知
- 29. iPhoneでのシングルトンと通知のベストプラクティス
- 30. 通知システムとphpとsocket.io
は[CKSubscription(https://developer.apple.com/library/prerelease/ios/documentation/CloudKit/Reference/CKSubscription_class/index.html)を見てください。 – tktsubota
この回答をお読みください:http://stackoverflow.com/a/38171514/2725435 –