From 2e4891e42ee99e1bcb52eefde521792a9d0d05b2 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Thu, 29 Dec 2016 17:21:55 -0500 Subject: [PATCH] cloud kit sub --- .../Search/RecentSearchController.swift | 3 ++ Kiwix.xcodeproj/project.pbxproj | 12 ++++++ Kiwix/Cloud/Cloud.swift | 40 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 Kiwix/Cloud/Cloud.swift diff --git a/Kiwix-iOS/Controller/Search/RecentSearchController.swift b/Kiwix-iOS/Controller/Search/RecentSearchController.swift index 5a8d4365..6e73eea0 100644 --- a/Kiwix-iOS/Controller/Search/RecentSearchController.swift +++ b/Kiwix-iOS/Controller/Search/RecentSearchController.swift @@ -57,6 +57,9 @@ class RecentSearchController: UIViewController, UICollectionViewDataSource, UICo // MARK: - CollectionView Delegate func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + guard let mainVC = parent?.parent?.parent as? MainController else {return} + print("tapped") + // guard let mainVC = parent?.parent?.parent as? MainController, // let searchController = parent?.parent as? SearchController, // let cell = collectionView.cellForItem(at: indexPath) as? LocalLangCell, diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj index d87b6985..cd569751 100644 --- a/Kiwix.xcodeproj/project.pbxproj +++ b/Kiwix.xcodeproj/project.pbxproj @@ -74,6 +74,7 @@ 9779C3141D4575AD0064CC8E /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 97E609F01D103DED00EBCB9D /* NotificationCenter.framework */; }; 9779C3171D4575AE0064CC8E /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9779C3161D4575AE0064CC8E /* TodayViewController.swift */; }; 9779C31E1D4575AE0064CC8E /* Bookmarks.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 9779C3131D4575AD0064CC8E /* Bookmarks.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 977A458C1E14EA140089C596 /* Cloud.swift in Sources */ = {isa = PBXBuildFile; fileRef = 977A458B1E14EA140089C596 /* Cloud.swift */; }; 977AE7F91DD8F22400F1E581 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A102A1D022AD5007FC62C /* SearchBar.swift */; }; 977B954D1DD4C40400F6F62B /* ScanLocalBook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811E1D6F70AC00E5FA99 /* ScanLocalBook.swift */; }; 97A08C151DD263B90070D0E4 /* Book.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D681341D6F711A00E5FA99 /* Book.swift */; }; @@ -232,6 +233,7 @@ 9779C3131D4575AD0064CC8E /* Bookmarks.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = Bookmarks.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 9779C3161D4575AE0064CC8E /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = ""; }; 9779C31B1D4575AE0064CC8E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 977A458B1E14EA140089C596 /* Cloud.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cloud.swift; sourceTree = ""; }; 9788419C1DA2FF2A00D22D3C /* MainInterface.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainInterface.storyboard; sourceTree = ""; }; 97A127C51D777CF100FB204D /* RecentSearchController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecentSearchController.swift; sourceTree = ""; }; 97A127C61D777CF100FB204D /* SearchScopeAndHistoryController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchScopeAndHistoryController.swift; sourceTree = ""; }; @@ -511,6 +513,7 @@ 973BCD1F1CEB412E00F10B44 /* Shared */ = { isa = PBXGroup; children = ( + 977A458A1E14E98F0089C596 /* Cloud */, 9711872D1CEB507600B9909D /* CoreData */, 97163D321CD7E79F008BE2D6 /* Help Docs */, 974C495E1DA307FF00E276E1 /* JavaScripts */, @@ -609,6 +612,14 @@ path = Bookmarks; sourceTree = ""; }; + 977A458A1E14E98F0089C596 /* Cloud */ = { + isa = PBXGroup; + children = ( + 977A458B1E14EA140089C596 /* Cloud.swift */, + ); + path = Cloud; + sourceTree = ""; + }; 9787BC1F1D9318080030D311 /* Others */ = { isa = PBXGroup; children = ( @@ -1108,6 +1119,7 @@ 97A1FD3B1D6F724E00A80EE2 /* stringTools.cpp in Sources */, 970E7F741D9DB0FC00741290 /* 1.8.xcmappingmodel in Sources */, 973207A01DD1983D00EDD3DC /* DownloadTasksController.swift in Sources */, + 977A458C1E14EA140089C596 /* Cloud.swift in Sources */, 97D0E9931DDA487E0029530E /* SearchBaseController.swift in Sources */, 97A1FD321D6F723D00A80EE2 /* resourceTools.cpp in Sources */, 97A1FD451D6F728200A80EE2 /* StringTools.swift in Sources */, diff --git a/Kiwix/Cloud/Cloud.swift b/Kiwix/Cloud/Cloud.swift new file mode 100644 index 00000000..d92fb040 --- /dev/null +++ b/Kiwix/Cloud/Cloud.swift @@ -0,0 +1,40 @@ +// +// Cloud.swift +// Kiwix +// +// Created by Chris Li on 12/29/16. +// Copyright © 2016 Chris Li. All rights reserved. +// + +import CloudKit + +class Cloud { + class var privateDatabase: CKDatabase { + return CKContainer.default().privateCloudDatabase + } + + + class func subscribeForChanges() { + let subscription = CKDatabaseSubscription(subscriptionID: "") + subscription.notificationInfo = CKNotificationInfo() + subscription.notificationInfo?.shouldSendContentAvailable = true + + let operation = CKModifySubscriptionsOperation(subscriptionsToSave: [subscription], subscriptionIDsToDelete: nil) + operation.qualityOfService = .utility + operation.modifySubscriptionsCompletionBlock = { saved, deleted, error in + if let error = error { + // handle error + } else { + //seuscriptionIsLocallyCached = true + } + } + // add to a database's operation queue + privateDatabase.add(operation) + + } + + class func handlePush() { + + } + +}