Skip to content

Commit

Permalink
use constant
Browse files Browse the repository at this point in the history
  • Loading branch information
caiyue1993 committed Dec 9, 2017
1 parent a6a7fdd commit 3878fbd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Example/IceCream/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let dict = userInfo as! [String: NSObject]
let notification = CKNotification(fromRemoteNotificationDictionary: dict)

if (notification.subscriptionID == IceCreamKey.cloudKitSubscriptionID.value) {
if (notification.subscriptionID == IceCreamConstant.cloudKitSubscriptionID) {
NotificationCenter.default.post(name: Notifications.cloudKitDataDidChangeRemotely.name, object: nil, userInfo: userInfo)
}
completionHandler(.newData)
Expand Down
3 changes: 1 addition & 2 deletions Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use_frameworks!

target 'IceCream_Example' do
# pod 'IceCream', :path => '../'
pod 'IceCream', '~> 1.0.0'
pod 'IceCream', :path => '../'
pod 'RxRealm'

target 'IceCream_Tests' do
Expand Down
9 changes: 5 additions & 4 deletions IceCream/Classes/SyncEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ public enum IceCreamKey: String {
case subscriptionIsLocallyCachedKey
case hasCustomZoneCreatedKey

/// Others
case cloudKitSubscriptionID

public var value: String {
return "icecream.keys." + rawValue
}
}

public struct IceCreamConstant {
public static let cloudKitSubscriptionID = "private_changes"
}

public final class SyncEngine<T: Object & CKRecordConvertible & CKRecordRecoverable> {

/// Notifications are delivered as long as a reference is held to the returned notification token. You should keep a strong reference to this token on the class registering for updates, as notifications are automatically unregistered when the notification token is deallocated.
Expand Down Expand Up @@ -366,7 +367,7 @@ extension SyncEngine {
*/

/// So I use the @Guilherme Rambo's plan: https://github.com/insidegui/NoteTaker
let subscription = CKQuerySubscription(recordType: T.recordType, predicate: NSPredicate(value: true), subscriptionID: IceCreamKey.cloudKitSubscriptionID.value, options: [.firesOnRecordCreation, .firesOnRecordUpdate, .firesOnRecordDeletion])
let subscription = CKQuerySubscription(recordType: T.recordType, predicate: NSPredicate(value: true), subscriptionID: IceCreamConstant.cloudKitSubscriptionID, options: [.firesOnRecordCreation, .firesOnRecordUpdate, .firesOnRecordDeletion])
let notificationInfo = CKNotificationInfo()
notificationInfo.shouldSendContentAvailable = true // Silent Push
subscription.notificationInfo = notificationInfo
Expand Down

0 comments on commit 3878fbd

Please sign in to comment.