mirror of
https://github.com/TermiT/Flycut.git
synced 2025-09-17 02:24:26 +08:00
Changes to go with update to MJCloudKitUserDefaultsSync d6b4a8431df171320bff7693a36a1bdec69b69e6
This commit is contained in:
parent
6df5dfc8be
commit
64643088f5
5 changed files with 25 additions and 25 deletions
|
@ -89,17 +89,17 @@
|
|||
- (void)registerOrDeregisterICloudSync
|
||||
{
|
||||
if ( [[NSUserDefaults standardUserDefaults] boolForKey:@"syncSettingsViaICloud"] ) {
|
||||
[MJCloudKitUserDefaultsSync removeNotificationsFor:MJSyncNotificationChanges forTarget:self];
|
||||
[MJCloudKitUserDefaultsSync addNotificationFor:MJSyncNotificationChanges withSelector:@selector(checkPreferencesChanges:) withTarget: self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] removeNotificationsFor:MJSyncNotificationChanges forTarget:self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] addNotificationFor:MJSyncNotificationChanges withSelector:@selector(checkPreferencesChanges:) withTarget: self];
|
||||
// Not registering for conflict notifications, since we just sync settings, and if the settings are conflictingly adjusted simultaneously on two systems there is nothing to say which setting is better.
|
||||
|
||||
[MJCloudKitUserDefaultsSync startWithKeyMatchList:settingsSyncList
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] startWithKeyMatchList:settingsSyncList
|
||||
withContainerIdentifier:@"iCloud.com.mark-a-jerde.Flycut"];
|
||||
}
|
||||
else {
|
||||
[MJCloudKitUserDefaultsSync stopForKeyMatchList:settingsSyncList];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] stopForKeyMatchList:settingsSyncList];
|
||||
|
||||
[MJCloudKitUserDefaultsSync removeNotificationsFor:MJSyncNotificationChanges forTarget:self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] removeNotificationsFor:MJSyncNotificationChanges forTarget:self];
|
||||
}
|
||||
|
||||
[flycutOperator registerOrDeregisterICloudSync];
|
||||
|
@ -928,13 +928,13 @@
|
|||
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||
// Forward the token to your provider, using a custom method.
|
||||
NSLog(@"Registered for remote notifications.");
|
||||
[MJCloudKitUserDefaultsSync setRemoteNotificationsEnabled:YES];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] setRemoteNotificationsEnabled:YES];
|
||||
}
|
||||
|
||||
- (void)application:(NSApplication *)application
|
||||
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
||||
NSLog(@"Remote notification support is unavailable due to error: %@", error);
|
||||
[MJCloudKitUserDefaultsSync setRemoteNotificationsEnabled:NO];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] setRemoteNotificationsEnabled:NO];
|
||||
}
|
||||
|
||||
- (void)application:(NSApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
|
||||
|
|
|
@ -23,7 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||
}
|
||||
} else {
|
||||
// Run without remote notifications for earlier versions
|
||||
MJCloudKitUserDefaultsSync.setRemoteNotificationsEnabled(false)
|
||||
MJCloudKitUserDefaultsSync.shared()?.setRemoteNotificationsEnabled(false)
|
||||
}
|
||||
application.registerForRemoteNotifications()
|
||||
|
||||
|
@ -33,7 +33,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||
// Called by push notifications when a CloudKit change occurs.
|
||||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
||||
// Notification was generated by CloudKit changes, so check for updates.
|
||||
MJCloudKitUserDefaultsSync.checkCloudKitUpdates()
|
||||
MJCloudKitUserDefaultsSync.shared()?.checkCloudKitUpdates()
|
||||
// Signal that we have completed our response to notification, with
|
||||
// parameter assuming that we received new data.
|
||||
completionHandler(.newData)
|
||||
|
@ -44,13 +44,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
|
||||
print(deviceTokenString)
|
||||
|
||||
MJCloudKitUserDefaultsSync.setRemoteNotificationsEnabled(true)
|
||||
MJCloudKitUserDefaultsSync.shared()?.setRemoteNotificationsEnabled(true)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
||||
|
||||
print("i am not available in simulator \(error)")
|
||||
MJCloudKitUserDefaultsSync.setRemoteNotificationsEnabled(false)
|
||||
MJCloudKitUserDefaultsSync.shared()?.setRemoteNotificationsEnabled(false)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class SettingsViewController: IASKAppSettingsViewController {
|
|||
let contents = try? String.init(contentsOfFile: fileRoot!, encoding: String.Encoding.utf8)
|
||||
UserDefaults.standard.set(contents, forKey: "acknowledgementsText")
|
||||
|
||||
let data = MJCloudKitUserDefaultsSync.diagnosticData()
|
||||
let data = MJCloudKitUserDefaultsSync.shared()?.diagnosticData()
|
||||
UserDefaults.standard.set(data, forKey: "diagnosticsText")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
|
|||
// Use this command to get screenshots:
|
||||
// while true; do xcrun simctl io booted screenshot;sleep 1;done
|
||||
|
||||
MJCloudKitUserDefaultsSync.setDelegate(self)
|
||||
MJCloudKitUserDefaultsSync.shared()?.setDelegate(self)
|
||||
|
||||
if ( UserDefaults.standard.bool(forKey: "demoForAppStoreScreenshots") )
|
||||
{
|
||||
|
|
|
@ -559,11 +559,11 @@
|
|||
-(void) registerOrDeregisterICloudSync
|
||||
{
|
||||
if ( [[NSUserDefaults standardUserDefaults] boolForKey:@"syncSettingsViaICloud"] ) {
|
||||
[MJCloudKitUserDefaultsSync startWithKeyMatchList:settingsSyncList
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] startWithKeyMatchList:settingsSyncList
|
||||
withContainerIdentifier:@"iCloud.com.mark-a-jerde.Flycut"];
|
||||
}
|
||||
else {
|
||||
[MJCloudKitUserDefaultsSync stopForKeyMatchList:settingsSyncList];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] stopForKeyMatchList:settingsSyncList];
|
||||
}
|
||||
|
||||
BOOL syncClippings = [[NSUserDefaults standardUserDefaults] boolForKey:@"syncClippingsViaICloud"];
|
||||
|
@ -579,22 +579,22 @@
|
|||
if ( changedSyncClippings )
|
||||
firstClippingsSyncAfterEnabling = YES;
|
||||
|
||||
[MJCloudKitUserDefaultsSync removeNotificationsFor:MJSyncNotificationChanges forTarget:self];
|
||||
[MJCloudKitUserDefaultsSync addNotificationFor:MJSyncNotificationChanges withSelector:@selector(checkPreferencesChanges:) withTarget: self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] removeNotificationsFor:MJSyncNotificationChanges forTarget:self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] addNotificationFor:MJSyncNotificationChanges withSelector:@selector(checkPreferencesChanges:) withTarget: self];
|
||||
|
||||
[MJCloudKitUserDefaultsSync removeNotificationsFor:MJSyncNotificationConflicts forTarget:self];
|
||||
[MJCloudKitUserDefaultsSync addNotificationFor:MJSyncNotificationConflicts withSelector:@selector(checkPreferencesConflicts:) withTarget: self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] removeNotificationsFor:MJSyncNotificationConflicts forTarget:self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] addNotificationFor:MJSyncNotificationConflicts withSelector:@selector(checkPreferencesConflicts:) withTarget: self];
|
||||
|
||||
[MJCloudKitUserDefaultsSync removeNotificationsFor:MJSyncNotificationSaveSuccess forTarget:self];
|
||||
[MJCloudKitUserDefaultsSync addNotificationFor:MJSyncNotificationSaveSuccess withSelector:@selector(checkPreferencesSaveSuccess:) withTarget: self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] removeNotificationsFor:MJSyncNotificationSaveSuccess forTarget:self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] addNotificationFor:MJSyncNotificationSaveSuccess withSelector:@selector(checkPreferencesSaveSuccess:) withTarget: self];
|
||||
|
||||
[MJCloudKitUserDefaultsSync startWithKeyMatchList:@[@"store"]
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] startWithKeyMatchList:@[@"store"]
|
||||
withContainerIdentifier:@"iCloud.com.mark-a-jerde.Flycut"];
|
||||
}
|
||||
else {
|
||||
[MJCloudKitUserDefaultsSync removeNotificationsFor:MJSyncNotificationChanges forTarget:self];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] removeNotificationsFor:MJSyncNotificationChanges forTarget:self];
|
||||
|
||||
[MJCloudKitUserDefaultsSync stopForKeyMatchList:@[@"store"]];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] stopForKeyMatchList:@[@"store"]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -914,7 +914,7 @@
|
|||
|
||||
-(void) checkCloudKitUpdates
|
||||
{
|
||||
[MJCloudKitUserDefaultsSync checkCloudKitUpdates];
|
||||
[[MJCloudKitUserDefaultsSync sharedSync] checkCloudKitUpdates];
|
||||
}
|
||||
|
||||
-(bool) loadEngineFrom:(NSDictionary*)loadDict key:(NSString*)listKey into:(FlycutStore*)store
|
||||
|
|
Loading…
Add table
Reference in a new issue