├── .gitignore ├── Bolts.framework ├── Bolts ├── Headers │ ├── BFAppLink.h │ ├── BFAppLinkNavigation.h │ ├── BFAppLinkResolving.h │ ├── BFAppLinkReturnToRefererController.h │ ├── BFAppLinkReturnToRefererView.h │ ├── BFAppLinkTarget.h │ ├── BFExecutor.h │ ├── BFMeasurementEvent.h │ ├── BFTask.h │ ├── BFTaskCompletionSource.h │ ├── BFURL.h │ ├── BFWebViewAppLinkResolver.h │ ├── Bolts.h │ └── BoltsVersion.h ├── Info.plist └── Modules │ └── module.modulemap ├── CloudCode ├── cloud │ └── main.js └── public │ └── index.html ├── Parse.framework ├── Headers │ ├── PFACL.h │ ├── PFAnalytics.h │ ├── PFAnonymousUtils.h │ ├── PFCloud.h │ ├── PFConfig.h │ ├── PFConstants.h │ ├── PFFile.h │ ├── PFGeoPoint.h │ ├── PFInstallation.h │ ├── PFNetworkActivityIndicatorManager.h │ ├── PFNullability.h │ ├── PFObject+Subclass.h │ ├── PFObject.h │ ├── PFProduct.h │ ├── PFPurchase.h │ ├── PFPush.h │ ├── PFQuery.h │ ├── PFRelation.h │ ├── PFRole.h │ ├── PFSubclassing.h │ ├── PFTwitterUtils.h │ ├── PFUser.h │ ├── PF_Twitter.h │ └── Parse.h ├── Info.plist ├── Modules │ └── module.modulemap ├── Parse ├── Resources │ └── Localizable.strings └── third_party_licenses.txt ├── ParseUI.framework ├── Headers │ ├── PFCollectionViewCell.h │ ├── PFImageView.h │ ├── PFLogInView.h │ ├── PFLogInViewController.h │ ├── PFProductTableViewController.h │ ├── PFPurchaseTableViewCell.h │ ├── PFQueryCollectionViewController.h │ ├── PFQueryTableViewController.h │ ├── PFSignUpView.h │ ├── PFSignUpViewController.h │ ├── PFTableViewCell.h │ ├── PFTextField.h │ ├── ParseUI.h │ └── ParseUIConstants.h ├── Info.plist ├── Modules │ └── module.modulemap └── ParseUI ├── README.md ├── ble-swift.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── ble-swift ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── CentralManager.swift ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Info.plist ├── Logger.swift ├── MainViewController.swift ├── NearbyTableViewController.swift ├── Peripheral.swift ├── PeripheralManager.swift ├── ProfileViewController.swift ├── RadarViewController.swift ├── SelectPeripheralViewController.swift └── Utilities │ └── Utils.swift └── ble-swiftTests ├── Info.plist └── ble_swiftTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | Keys.plist 4 | CloudCode/config/ 5 | .DS_Store 6 | .dropbox.attr 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # CocoaPods 25 | # 26 | # We recommend against adding the Pods directory to your .gitignore. However 27 | # you should judge for yourself, the pros and cons are mentioned at: 28 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 29 | # 30 | # Pods/ 31 | -------------------------------------------------------------------------------- /Bolts.framework/Bolts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyuanme/ble-swift/7d706c6d4219e250c10c05db0a36bbea0cb24bc3/Bolts.framework/Bolts -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFAppLink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | /*! The version of the App Link protocol that this library supports */ 14 | FOUNDATION_EXPORT NSString *const BFAppLinkVersion; 15 | 16 | /*! 17 | Contains App Link metadata relevant for navigation on this device 18 | derived from the HTML at a given URL. 19 | */ 20 | @interface BFAppLink : NSObject 21 | 22 | /*! 23 | Creates a BFAppLink with the given list of BFAppLinkTargets and target URL. 24 | 25 | Generally, this will only be used by implementers of the BFAppLinkResolving protocol, 26 | as these implementers will produce App Link metadata for a given URL. 27 | 28 | @param sourceURL the URL from which this App Link is derived 29 | @param targets an ordered list of BFAppLinkTargets for this platform derived 30 | from App Link metadata. 31 | @param webURL the fallback web URL, if any, for the app link. 32 | */ 33 | + (instancetype)appLinkWithSourceURL:(NSURL *)sourceURL 34 | targets:(NSArray *)targets 35 | webURL:(NSURL *)webURL; 36 | 37 | /*! The URL from which this BFAppLink was derived */ 38 | @property (nonatomic, strong, readonly) NSURL *sourceURL; 39 | 40 | /*! 41 | The ordered list of targets applicable to this platform that will be used 42 | for navigation. 43 | */ 44 | @property (nonatomic, copy, readonly) NSArray *targets; 45 | 46 | /*! The fallback web URL to use if no targets are installed on this device. */ 47 | @property (nonatomic, strong, readonly) NSURL *webURL; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFAppLinkNavigation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | #import 14 | 15 | /*! 16 | The result of calling navigate on a BFAppLinkNavigation 17 | */ 18 | typedef NS_ENUM(NSInteger, BFAppLinkNavigationType) { 19 | /*! Indicates that the navigation failed and no app was opened */ 20 | BFAppLinkNavigationTypeFailure, 21 | /*! Indicates that the navigation succeeded by opening the URL in the browser */ 22 | BFAppLinkNavigationTypeBrowser, 23 | /*! Indicates that the navigation succeeded by opening the URL in an app on the device */ 24 | BFAppLinkNavigationTypeApp 25 | }; 26 | 27 | @protocol BFAppLinkResolving; 28 | @class BFTask; 29 | 30 | /*! 31 | Represents a pending request to navigate to an App Link. Most developers will 32 | simply use navigateToURLInBackground: to open a URL, but developers can build 33 | custom requests with additional navigation and app data attached to them by 34 | creating BFAppLinkNavigations themselves. 35 | */ 36 | @interface BFAppLinkNavigation : NSObject 37 | 38 | /*! 39 | The extras for the AppLinkNavigation. This will generally contain application-specific 40 | data that should be passed along with the request, such as advertiser or affiliate IDs or 41 | other such metadata relevant on this device. 42 | */ 43 | @property (nonatomic, copy, readonly) NSDictionary *extras; 44 | 45 | /*! 46 | The al_applink_data for the AppLinkNavigation. This will generally contain data common to 47 | navigation attempts such as back-links, user agents, and other information that may be used 48 | in routing and handling an App Link request. 49 | */ 50 | @property (nonatomic, copy, readonly) NSDictionary *appLinkData; 51 | 52 | /*! The AppLink to navigate to */ 53 | @property (nonatomic, strong, readonly) BFAppLink *appLink; 54 | 55 | /*! Creates an AppLinkNavigation with the given link, extras, and App Link data */ 56 | + (instancetype)navigationWithAppLink:(BFAppLink *)appLink 57 | extras:(NSDictionary *)extras 58 | appLinkData:(NSDictionary *)appLinkData; 59 | 60 | /*! Performs the navigation */ 61 | - (BFAppLinkNavigationType)navigate:(NSError **)error; 62 | 63 | /*! Returns a BFAppLink for the given URL */ 64 | + (BFTask *)resolveAppLinkInBackground:(NSURL *)destination; 65 | 66 | /*! Returns a BFAppLink for the given URL using the given App Link resolution strategy */ 67 | + (BFTask *)resolveAppLinkInBackground:(NSURL *)destination resolver:(id)resolver; 68 | 69 | /*! Navigates to a BFAppLink and returns whether it opened in-app or in-browser */ 70 | + (BFAppLinkNavigationType)navigateToAppLink:(BFAppLink *)link error:(NSError **)error; 71 | 72 | /*! Navigates to a URL (an asynchronous action) and returns a BFNavigationType */ 73 | + (BFTask *)navigateToURLInBackground:(NSURL *)destination; 74 | 75 | /*! 76 | Navigates to a URL (an asynchronous action) using the given App Link resolution 77 | strategy and returns a BFNavigationType 78 | */ 79 | + (BFTask *)navigateToURLInBackground:(NSURL *)destination resolver:(id)resolver; 80 | 81 | /*! 82 | Gets the default resolver to be used for App Link resolution. If the developer has not set one explicitly, 83 | a basic, built-in resolver will be used. 84 | */ 85 | + (id)defaultResolver; 86 | 87 | /*! 88 | Sets the default resolver to be used for App Link resolution. Setting this to nil will revert the 89 | default resolver to the basic, built-in resolver provided by Bolts. 90 | */ 91 | + (void)setDefaultResolver:(id)resolver; 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFAppLinkResolving.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | @class BFTask; 14 | 15 | /*! 16 | Implement this protocol to provide an alternate strategy for resolving 17 | App Links that may include pre-fetching, caching, or querying for App Link 18 | data from an index provided by a service provider. 19 | */ 20 | @protocol BFAppLinkResolving 21 | 22 | /*! 23 | Asynchronously resolves App Link data for a given URL. 24 | 25 | @param url The URL to resolve into an App Link. 26 | @returns A BFTask that will return a BFAppLink for the given URL. 27 | */ 28 | - (BFTask *)appLinkFromURLInBackground:(NSURL *)url; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFAppLinkReturnToRefererController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | #import 13 | 14 | #import 15 | 16 | @class BFAppLink; 17 | @class BFAppLinkReturnToRefererController; 18 | 19 | /*! 20 | Protocol that a class can implement in order to be notified when the user has navigated back 21 | to the referer of an App Link. 22 | */ 23 | @protocol BFAppLinkReturnToRefererControllerDelegate 24 | 25 | @optional 26 | 27 | /*! Called when the user has tapped to navigate, but before the navigation has been performed. */ 28 | - (void)returnToRefererController:(BFAppLinkReturnToRefererController *)controller 29 | willNavigateToAppLink:(BFAppLink *)appLink; 30 | 31 | /*! Called after the navigation has been attempted, with an indication of whether the referer 32 | app link was successfully opened. */ 33 | - (void)returnToRefererController:(BFAppLinkReturnToRefererController *)controller 34 | didNavigateToAppLink:(BFAppLink *)url 35 | type:(BFAppLinkNavigationType)type; 36 | 37 | @end 38 | 39 | /*! 40 | A controller class that implements default behavior for a BFAppLinkReturnToRefererView, including 41 | the ability to display the view above the navigation bar for navigation-bsaed apps. 42 | */ 43 | @interface BFAppLinkReturnToRefererController : NSObject 44 | 45 | /*! 46 | The delegate that will be notified when the user navigates back to the referer. 47 | */ 48 | @property (nonatomic, weak) id delegate; 49 | 50 | /*! 51 | The BFAppLinkReturnToRefererView this controller is controlling. 52 | */ 53 | @property (nonatomic, strong) BFAppLinkReturnToRefererView *view; 54 | 55 | /*! 56 | Initializes a controller suitable for controlling a BFAppLinkReturnToRefererView that is to be displayed 57 | contained within another UIView (i.e., not displayed above the navigation bar). 58 | */ 59 | - (instancetype)init; 60 | 61 | /*! 62 | Initializes a controller suitable for controlling a BFAppLinkReturnToRefererView that is to be displayed 63 | displayed above the navigation bar. 64 | */ 65 | - (instancetype)initForDisplayAboveNavController:(UINavigationController *)navController; 66 | 67 | /*! 68 | Removes the view entirely from the navigation controller it is currently displayed in. 69 | */ 70 | - (void)removeFromNavController; 71 | 72 | /*! 73 | Shows the BFAppLinkReturnToRefererView with the specified referer information. If nil or missing data, 74 | the view will not be displayed. */ 75 | - (void)showViewForRefererAppLink:(BFAppLink *)refererAppLink; 76 | 77 | /*! 78 | Shows the BFAppLinkReturnToRefererView with referer information extracted from the specified URL. 79 | If nil or missing referer App Link data, the view will not be displayed. */ 80 | - (void)showViewForRefererURL:(NSURL *)url; 81 | 82 | /*! 83 | Closes the view, possibly animating it. 84 | */ 85 | - (void)closeViewAnimated:(BOOL)animated; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFAppLinkReturnToRefererView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | #import 13 | 14 | #import 15 | 16 | @class BFAppLinkReturnToRefererView; 17 | @class BFURL; 18 | 19 | typedef enum BFIncludeStatusBarInSize { 20 | BFIncludeStatusBarInSizeNever, 21 | BFIncludeStatusBarInSizeIOS7AndLater, 22 | BFIncludeStatusBarInSizeAlways, 23 | } BFIncludeStatusBarInSize; 24 | 25 | /*! 26 | Protocol that a class can implement in order to be notified when the user has navigated back 27 | to the referer of an App Link. 28 | */ 29 | @protocol BFAppLinkReturnToRefererViewDelegate 30 | 31 | /*! 32 | Called when the user has tapped inside the close button. 33 | */ 34 | - (void)returnToRefererViewDidTapInsideCloseButton:(BFAppLinkReturnToRefererView *)view; 35 | 36 | /*! 37 | Called when the user has tapped inside the App Link portion of the view. 38 | */ 39 | - (void)returnToRefererViewDidTapInsideLink:(BFAppLinkReturnToRefererView *)view 40 | link:(BFAppLink *)link; 41 | 42 | @end 43 | 44 | /*! 45 | Provides a UIView that displays a button allowing users to navigate back to the 46 | application that launched the App Link currently being handled, if the App Link 47 | contained referer data. The user can also close the view by clicking a close button 48 | rather than navigating away. If the view is provided an App Link that does not contain 49 | referer data, it will have zero size and no UI will be displayed. 50 | */ 51 | @interface BFAppLinkReturnToRefererView : UIView 52 | 53 | /*! 54 | The delegate that will be notified when the user navigates back to the referer. 55 | */ 56 | @property (nonatomic, weak) id delegate; 57 | 58 | /*! 59 | The color of the text label and close button. 60 | */ 61 | @property (nonatomic, strong) UIColor *textColor; 62 | 63 | @property (nonatomic, strong) BFAppLink *refererAppLink; 64 | 65 | /*! 66 | Indicates whether to extend the size of the view to include the current status bar 67 | size, for use in scenarios where the view might extend under the status bar on iOS 7 and 68 | above; this property has no effect on earlier versions of iOS. 69 | */ 70 | @property (nonatomic, assign) BFIncludeStatusBarInSize includeStatusBarInSize; 71 | 72 | /*! 73 | Indicates whether the user has closed the view by clicking the close button. 74 | */ 75 | @property (nonatomic, assign) BOOL closed; 76 | 77 | /*! 78 | For apps that use a navigation controller, this method allows for displaying the view as 79 | a banner above the navigation bar of the navigation controller. It will listen for orientation 80 | change and other events to ensure it stays properly positioned above the nevigation bar. 81 | If this method is called from, e.g., viewDidAppear, its counterpart, detachFromMainWindow should 82 | be called from, e.g., viewWillDisappear. 83 | */ 84 | //- (void)attachToMainWindowAboveNavigationController:(UINavigationController *)navigationController view:(UIView *)view; 85 | 86 | /*! 87 | Indicates that the view should no longer position itself above a navigation bar. 88 | */ 89 | //- (void)detachFromMainWindow; 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFAppLinkTarget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | /*! 14 | Represents a target defined in App Link metadata, consisting of at least 15 | a URL, and optionally an App Store ID and name. 16 | */ 17 | @interface BFAppLinkTarget : NSObject 18 | 19 | /*! Creates a BFAppLinkTarget with the given app site and target URL. */ 20 | + (instancetype)appLinkTargetWithURL:(NSURL *)url 21 | appStoreId:(NSString *)appStoreId 22 | appName:(NSString *)appName; 23 | 24 | /*! The URL prefix for this app link target */ 25 | @property (nonatomic, strong, readonly) NSURL *URL; 26 | 27 | /*! The app ID for the app store */ 28 | @property (nonatomic, copy, readonly) NSString *appStoreId; 29 | 30 | /*! The name of the app */ 31 | @property (nonatomic, copy, readonly) NSString *appName; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFExecutor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | /*! 14 | An object that can run a given block. 15 | */ 16 | @interface BFExecutor : NSObject 17 | 18 | /*! 19 | Returns a default executor, which runs continuations immediately until the call stack gets too 20 | deep, then dispatches to a new GCD queue. 21 | */ 22 | + (instancetype)defaultExecutor; 23 | 24 | /*! 25 | Returns an executor that runs continuations on the thread where the previous task was completed. 26 | */ 27 | + (instancetype)immediateExecutor; 28 | 29 | /*! 30 | Returns an executor that runs continuations on the main thread. 31 | */ 32 | + (instancetype)mainThreadExecutor; 33 | 34 | /*! 35 | Returns a new executor that uses the given block to execute continuations. 36 | @param block The block to use. 37 | */ 38 | + (instancetype)executorWithBlock:(void(^)(void(^block)()))block; 39 | 40 | /*! 41 | Returns a new executor that runs continuations on the given queue. 42 | @param queue The instance of `dispatch_queue_t` to dispatch all continuations onto. 43 | */ 44 | + (instancetype)executorWithDispatchQueue:(dispatch_queue_t)queue; 45 | 46 | /*! 47 | Returns a new executor that runs continuations on the given queue. 48 | @param queue The instance of `NSOperationQueue` to run all continuations on. 49 | */ 50 | + (instancetype)executorWithOperationQueue:(NSOperationQueue *)queue; 51 | 52 | /*! 53 | Runs the given block using this executor's particular strategy. 54 | @param block The block to execute. 55 | */ 56 | - (void)execute:(void(^)())block; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFMeasurementEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | /*! The name of the notification posted by BFMeasurementEvent */ 14 | FOUNDATION_EXPORT NSString *const BFMeasurementEventNotificationName; 15 | 16 | /*! Defines keys in the userInfo object for the notification named BFMeasurementEventNotificationName */ 17 | /*! The string field for the name of the event */ 18 | FOUNDATION_EXPORT NSString *const BFMeasurementEventNameKey; 19 | /*! The dictionary field for the arguments of the event */ 20 | FOUNDATION_EXPORT NSString *const BFMeasurementEventArgsKey; 21 | 22 | 23 | /*! Bolts Events raised by BFMeasurementEvent for Applink */ 24 | /*! 25 | The name of the event posted when [BFURL URLWithURL:] is called successfully. This represents the successful parsing of an app link URL. 26 | */ 27 | FOUNDATION_EXPORT NSString *const BFAppLinkParseEventName; 28 | 29 | /*! 30 | The name of the event posted when [BFURL URLWithInboundURL:] is called successfully. 31 | This represents parsing an inbound app link URL from a different application 32 | */ 33 | FOUNDATION_EXPORT NSString *const BFAppLinkNavigateInEventName; 34 | 35 | /*! The event raised when the user navigates from your app to other apps */ 36 | FOUNDATION_EXPORT NSString *const BFAppLinkNavigateOutEventName; 37 | 38 | /*! 39 | The event raised when the user navigates out from your app and back to the referrer app. 40 | e.g when the user leaves your app after tapping the back-to-referrer navigation bar 41 | */ 42 | FOUNDATION_EXPORT NSString *const BFAppLinkNavigateBackToReferrerEventName; 43 | 44 | @interface BFMeasurementEvent : NSObject 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFTask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | /*! 14 | Error domain used if there was multiple errors on . 15 | */ 16 | extern NSString *const BFTaskErrorDomain; 17 | 18 | /*! 19 | An exception that is thrown if there was multiple exceptions on . 20 | */ 21 | extern NSString *const BFTaskMultipleExceptionsException; 22 | 23 | @class BFExecutor; 24 | @class BFTask; 25 | 26 | /*! 27 | A block that can act as a continuation for a task. 28 | */ 29 | typedef id(^BFContinuationBlock)(BFTask *task); 30 | 31 | /*! 32 | The consumer view of a Task. A BFTask has methods to 33 | inspect the state of the task, and to add continuations to 34 | be run once the task is complete. 35 | */ 36 | @interface BFTask : NSObject 37 | 38 | /*! 39 | Creates a task that is already completed with the given result. 40 | @param result The result for the task. 41 | */ 42 | + (instancetype)taskWithResult:(id)result; 43 | 44 | /*! 45 | Creates a task that is already completed with the given error. 46 | @param error The error for the task. 47 | */ 48 | + (instancetype)taskWithError:(NSError *)error; 49 | 50 | /*! 51 | Creates a task that is already completed with the given exception. 52 | @param exception The exception for the task. 53 | */ 54 | + (instancetype)taskWithException:(NSException *)exception; 55 | 56 | /*! 57 | Creates a task that is already cancelled. 58 | */ 59 | + (instancetype)cancelledTask; 60 | 61 | /*! 62 | Returns a task that will be completed (with result == nil) once 63 | all of the input tasks have completed. 64 | @param tasks An `NSArray` of the tasks to use as an input. 65 | */ 66 | + (instancetype)taskForCompletionOfAllTasks:(NSArray *)tasks; 67 | 68 | /*! 69 | Returns a task that will be completed once all of the input tasks have completed. 70 | If all tasks complete successfully without being faulted or cancelled the result will be 71 | an `NSArray` of all task results in the order they were provided. 72 | @param tasks An `NSArray` of the tasks to use as an input. 73 | */ 74 | + (instancetype)taskForCompletionOfAllTasksWithResults:(NSArray *)tasks; 75 | 76 | /*! 77 | Returns a task that will be completed a certain amount of time in the future. 78 | @param millis The approximate number of milliseconds to wait before the 79 | task will be finished (with result == nil). 80 | */ 81 | + (instancetype)taskWithDelay:(int)millis; 82 | 83 | /*! 84 | Returns a task that will be completed after the given block completes with 85 | the specified executor. 86 | @param executor A BFExecutor responsible for determining how the 87 | continuation block will be run. 88 | @param block The block to immediately schedule to run with the given executor. 89 | @returns A task that will be completed after block has run. 90 | If block returns a BFTask, then the task returned from 91 | this method will not be completed until that task is completed. 92 | */ 93 | + (instancetype)taskFromExecutor:(BFExecutor *)executor 94 | withBlock:(id (^)())block; 95 | 96 | // Properties that will be set on the task once it is completed. 97 | 98 | /*! 99 | The result of a successful task. 100 | */ 101 | @property (nonatomic, strong, readonly) id result; 102 | 103 | 104 | /*! 105 | The error of a failed task. 106 | */ 107 | @property (nonatomic, strong, readonly) NSError *error; 108 | 109 | /*! 110 | The exception of a failed task. 111 | */ 112 | @property (nonatomic, strong, readonly) NSException *exception; 113 | 114 | /*! 115 | Whether this task has been cancelled. 116 | */ 117 | @property (nonatomic, assign, readonly, getter = isCancelled) BOOL cancelled; 118 | 119 | /*! 120 | Whether this task has completed due to an error or exception. 121 | */ 122 | @property (nonatomic, assign, readonly, getter = isFaulted) BOOL faulted; 123 | 124 | /*! 125 | Whether this task has completed. 126 | */ 127 | @property (nonatomic, assign, readonly, getter = isCompleted) BOOL completed; 128 | 129 | /*! 130 | Enqueues the given block to be run once this task is complete. 131 | This method uses a default execution strategy. The block will be 132 | run on the thread where the previous task completes, unless the 133 | the stack depth is too deep, in which case it will be run on a 134 | dispatch queue with default priority. 135 | @param block The block to be run once this task is complete. 136 | @returns A task that will be completed after block has run. 137 | If block returns a BFTask, then the task returned from 138 | this method will not be completed until that task is completed. 139 | */ 140 | - (instancetype)continueWithBlock:(BFContinuationBlock)block; 141 | 142 | /*! 143 | Enqueues the given block to be run once this task is complete. 144 | @param executor A BFExecutor responsible for determining how the 145 | continuation block will be run. 146 | @param block The block to be run once this task is complete. 147 | @returns A task that will be completed after block has run. 148 | If block returns a BFTask, then the task returned from 149 | this method will not be completed until that task is completed. 150 | */ 151 | - (instancetype)continueWithExecutor:(BFExecutor *)executor 152 | withBlock:(BFContinuationBlock)block; 153 | 154 | /*! 155 | Identical to continueWithBlock:, except that the block is only run 156 | if this task did not produce a cancellation, error, or exception. 157 | If it did, then the failure will be propagated to the returned 158 | task. 159 | @param block The block to be run once this task is complete. 160 | @returns A task that will be completed after block has run. 161 | If block returns a BFTask, then the task returned from 162 | this method will not be completed until that task is completed. 163 | */ 164 | - (instancetype)continueWithSuccessBlock:(BFContinuationBlock)block; 165 | 166 | /*! 167 | Identical to continueWithExecutor:withBlock:, except that the block 168 | is only run if this task did not produce a cancellation, error, or 169 | exception. If it did, then the failure will be propagated to the 170 | returned task. 171 | @param executor A BFExecutor responsible for determining how the 172 | continuation block will be run. 173 | @param block The block to be run once this task is complete. 174 | @returns A task that will be completed after block has run. 175 | If block returns a BFTask, then the task returned from 176 | this method will not be completed until that task is completed. 177 | */ 178 | - (instancetype)continueWithExecutor:(BFExecutor *)executor 179 | withSuccessBlock:(BFContinuationBlock)block; 180 | 181 | /*! 182 | Waits until this operation is completed. 183 | This method is inefficient and consumes a thread resource while 184 | it's running. It should be avoided. This method logs a warning 185 | message if it is used on the main thread. 186 | */ 187 | - (void)waitUntilFinished; 188 | 189 | @end 190 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFTaskCompletionSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | @class BFTask; 14 | 15 | /*! 16 | A BFTaskCompletionSource represents the producer side of tasks. 17 | It is a task that also has methods for changing the state of the 18 | task by settings its completion values. 19 | */ 20 | @interface BFTaskCompletionSource : NSObject 21 | 22 | /*! 23 | Creates a new unfinished task. 24 | */ 25 | + (instancetype)taskCompletionSource; 26 | 27 | /*! 28 | The task associated with this TaskCompletionSource. 29 | */ 30 | @property (nonatomic, retain, readonly) BFTask *task; 31 | 32 | /*! 33 | Completes the task by setting the result. 34 | Attempting to set this for a completed task will raise an exception. 35 | @param result The result of the task. 36 | */ 37 | - (void)setResult:(id)result; 38 | 39 | /*! 40 | Completes the task by setting the error. 41 | Attempting to set this for a completed task will raise an exception. 42 | @param error The error for the task. 43 | */ 44 | - (void)setError:(NSError *)error; 45 | 46 | /*! 47 | Completes the task by setting an exception. 48 | Attempting to set this for a completed task will raise an exception. 49 | @param exception The exception for the task. 50 | */ 51 | - (void)setException:(NSException *)exception; 52 | 53 | /*! 54 | Completes the task by marking it as cancelled. 55 | Attempting to set this for a completed task will raise an exception. 56 | */ 57 | - (void)cancel; 58 | 59 | /*! 60 | Sets the result of the task if it wasn't already completed. 61 | @returns whether the new value was set. 62 | */ 63 | - (BOOL)trySetResult:(id)result; 64 | 65 | /*! 66 | Sets the error of the task if it wasn't already completed. 67 | @param error The error for the task. 68 | @returns whether the new value was set. 69 | */ 70 | - (BOOL)trySetError:(NSError *)error; 71 | 72 | /*! 73 | Sets the exception of the task if it wasn't already completed. 74 | @param exception The exception for the task. 75 | @returns whether the new value was set. 76 | */ 77 | - (BOOL)trySetException:(NSException *)exception; 78 | 79 | /*! 80 | Sets the cancellation state of the task if it wasn't already completed. 81 | @returns whether the new value was set. 82 | */ 83 | - (BOOL)trySetCancelled; 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFURL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | 14 | 15 | @class BFAppLink; 16 | 17 | /*! 18 | Provides a set of utilities for working with NSURLs, such as parsing of query parameters 19 | and handling for App Link requests. 20 | */ 21 | @interface BFURL : NSObject 22 | 23 | /*! 24 | Creates a link target from a raw URL. 25 | On success, this posts the BFAppLinkParseEventName measurement event. If you are constructing the BFURL within your application delegate's 26 | application:openURL:sourceApplication:annotation:, you should instead use URLWithInboundURL:sourceApplication: 27 | to support better BFMeasurementEvent notifications 28 | @param url The instance of `NSURL` to create BFURL from. 29 | */ 30 | + (BFURL *)URLWithURL:(NSURL *)url; 31 | 32 | /*! 33 | Creates a link target from a raw URL received from an external application. This is typically called from the app delegate's 34 | application:openURL:sourceApplication:annotation: and will post the BFAppLinkNavigateInEventName measurement event. 35 | @param url The instance of `NSURL` to create BFURL from. 36 | @param sourceApplication the bundle ID of the app that is requesting your app to open the URL. The same sourceApplication in application:openURL:sourceApplication:annotation: 37 | */ 38 | + (BFURL *)URLWithInboundURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication; 39 | 40 | /*! 41 | Gets the target URL. If the link is an App Link, this is the target of the App Link. 42 | Otherwise, it is the url that created the target. 43 | */ 44 | @property (nonatomic, strong, readonly) NSURL *targetURL; 45 | 46 | /*! 47 | Gets the query parameters for the target, parsed into an NSDictionary. 48 | */ 49 | @property (nonatomic, strong, readonly) NSDictionary *targetQueryParameters; 50 | 51 | /*! 52 | If this link target is an App Link, this is the data found in al_applink_data. 53 | Otherwise, it is nil. 54 | */ 55 | @property (nonatomic, strong, readonly) NSDictionary *appLinkData; 56 | 57 | /*! 58 | If this link target is an App Link, this is the data found in extras. 59 | */ 60 | @property (nonatomic, strong, readonly) NSDictionary *appLinkExtras; 61 | 62 | /*! 63 | The App Link indicating how to navigate back to the referer app, if any. 64 | */ 65 | @property (nonatomic, strong, readonly) BFAppLink *appLinkReferer; 66 | 67 | /*! 68 | The URL that was used to create this BFURL. 69 | */ 70 | @property (nonatomic, strong, readonly) NSURL *inputURL; 71 | 72 | /*! 73 | The query parameters of the inputURL, parsed into an NSDictionary. 74 | */ 75 | @property (nonatomic, strong, readonly) NSDictionary *inputQueryParameters; 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BFWebViewAppLinkResolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | #import 14 | 15 | /*! 16 | A reference implementation for an App Link resolver that uses a hidden UIWebView 17 | to parse the HTML containing App Link metadata. 18 | */ 19 | @interface BFWebViewAppLinkResolver : NSObject 20 | 21 | /*! 22 | Gets the instance of a BFWebViewAppLinkResolver. 23 | */ 24 | + (instancetype)sharedInstance; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/Bolts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | #import 13 | #import 14 | #import 15 | 16 | #if TARGET_OS_IPHONE 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #endif 25 | 26 | /*! @abstract 80175001: There were multiple errors. */ 27 | extern NSInteger const kBFMultipleErrorsError; 28 | 29 | @interface Bolts : NSObject 30 | 31 | /*! 32 | Returns the version of the Bolts Framework as an NSString. 33 | @returns The NSString representation of the current version. 34 | */ 35 | + (NSString *)version; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Bolts.framework/Headers/BoltsVersion.h: -------------------------------------------------------------------------------- 1 | #define BOLTS_VERSION @"1.1.4" 2 | -------------------------------------------------------------------------------- /Bolts.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyuanme/ble-swift/7d706c6d4219e250c10c05db0a36bbea0cb24bc3/Bolts.framework/Info.plist -------------------------------------------------------------------------------- /Bolts.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module Bolts { 2 | umbrella header "Bolts.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /CloudCode/cloud/main.js: -------------------------------------------------------------------------------- 1 | var delayUntil; 2 | var delayPromise; 3 | 4 | var _delay = function () { 5 | if (Date.now() >= delayUntil) { 6 | delayPromise.resolve(); 7 | return; 8 | } else { 9 | process.nextTick(_delay); 10 | } 11 | } 12 | 13 | var delay = function(delayTime) { 14 | delayUntil = Date.now() + delayTime; 15 | delayPromise = new Parse.Promise(); 16 | _delay(); 17 | return delayPromise; 18 | }; 19 | 20 | var delayFoo = function(){ 21 | console.log("1"); 22 | }; 23 | 24 | Parse.Cloud.define("test", function(request, response) { 25 | delay(5000).then(delayFoo); 26 | console.log("2"); 27 | // response.success(); 28 | }); 29 | 30 | Parse.Cloud.job('scandiscovery', function(request, status) { 31 | const interval = 30 * 60 * 1000; // 30 min 32 | var Discovery = Parse.Object.extend("Discovery"); 33 | var discoveryQuery = new Parse.Query(Discovery); 34 | discoveryQuery.equalTo("pushed", true); // avoid to flip the too-frequently reported records 35 | discoveryQuery.notEqualTo("scanned", true); 36 | discoveryQuery.notEqualTo("derived", "flipped"); 37 | var d = new Date(); 38 | var timeNow = d.getTime(); 39 | var timeThen = timeNow - interval; 40 | var queryDate = new Date(); 41 | queryDate.setTime(timeThen); 42 | discoveryQuery.greaterThanOrEqualTo("updatedAt", queryDate); 43 | discoveryQuery.find({ 44 | success: function(results) { 45 | for (var i = 0; i < results.length; i++) { 46 | var discovery = results[i]; 47 | // switch fromDevice and discoveredDevice 48 | var switchedDiscovery = new Discovery(); 49 | switchedDiscovery.set("fromDevice", discovery.get("discoveredDevice")); 50 | switchedDiscovery.set("discoveredDevice", discovery.get("fromDevice")); 51 | switchedDiscovery.set("location", discovery.get("location")); 52 | switchedDiscovery.set("derived", "flipped"); 53 | switchedDiscovery.save(); 54 | discovery.set("scanned", true); 55 | discovery.save(); 56 | } 57 | status.success("Scan discovery job completed successfully."); 58 | }, 59 | error: function(error) { 60 | status.error(error); 61 | } 62 | }); 63 | }); 64 | 65 | // Before saving Discovery 66 | Parse.Cloud.beforeSave("Discovery", function(request, response) { 67 | if (request.object.get("derived") && !request.object.id) { // if it is new derived data 68 | const interval = 2 * 60 * 1000; // 2 mins 69 | var Discovery = Parse.Object.extend("Discovery"); 70 | var discoveryQuery = new Parse.Query(Discovery); 71 | discoveryQuery.equalTo("fromDevice", request.object.get("fromDevice")); 72 | discoveryQuery.equalTo("discoveredDevice", request.object.get("discoveredDevice")); 73 | var d = new Date(); 74 | var timeNow = d.getTime(); 75 | var timeThen = timeNow - interval; 76 | var queryDate = new Date(); 77 | queryDate.setTime(timeThen); 78 | discoveryQuery.greaterThanOrEqualTo("updatedAt", queryDate); 79 | discoveryQuery.find({ 80 | success: function(results) { 81 | if (results.length > 0) { 82 | response.error("Already exists this discovery"); 83 | } else { 84 | response.success(); 85 | } 86 | }, 87 | error: function(error) { 88 | response.error(error); 89 | } 90 | }); 91 | } else { 92 | response.success(); 93 | } 94 | }); 95 | 96 | // Push after saving new discovery 97 | Parse.Cloud.afterSave("Discovery", function(request) { 98 | if(!request.object.get("pushed")) { 99 | Parse.Cloud.run('pushdiscovery', { fromDevice: request.object.get("fromDevice").id, discoveredDevice: request.object.get("discoveredDevice").id }, { 100 | success: function(msg) { 101 | console.log(msg); 102 | request.object.set("pushed", true); 103 | request.object.save(); 104 | // Push the counterparty 105 | // delay does not work in afterSave, don't know the reason yet 106 | // delay(1000).then(delayPushDiscovery(request.object.get("discoveredDevice").id, request.object.get("fromDevice").id)); 107 | console.log("Introduce friends of " + request.object.get("fromDevice")); 108 | const interval = 2 * 60 * 1000; // 2 mins 109 | var Discovery = Parse.Object.extend("Discovery"); 110 | var discoveryQuery = new Parse.Query(Discovery); 111 | discoveryQuery.equalTo("fromDevice", request.object.get("fromDevice")); 112 | var d = new Date(); 113 | var timeNow = d.getTime(); 114 | var timeThen = timeNow - interval; 115 | var queryDate = new Date(); 116 | queryDate.setTime(timeThen); 117 | discoveryQuery.greaterThanOrEqualTo("updatedAt", queryDate); 118 | discoveryQuery.find({ 119 | success: function(results) { 120 | for (var i = 0; i < results.length; i++) { 121 | var discovery = results[i]; 122 | if (discovery.get("discoveredDevice").id != request.object.get("discoveredDevice").id) { 123 | var switchedDiscovery = new Discovery(); 124 | switchedDiscovery.set("fromDevice", request.object.get("discoveredDevice")); // Introduce friend A 125 | switchedDiscovery.set("discoveredDevice", discovery.get("discoveredDevice")); // to know friend B 126 | switchedDiscovery.set("location", request.object.get("location")); 127 | switchedDiscovery.set("derived", request.object.get("fromDevice").id); 128 | switchedDiscovery.save(); 129 | } 130 | } 131 | }, 132 | error: function(error) { 133 | console.error(error); 134 | } 135 | }); 136 | }, 137 | error: function(error) { 138 | console.error(error); 139 | } 140 | }); 141 | } 142 | }); 143 | 144 | var delayPushDiscovery = function(fromDevice, discoveredDevice) { 145 | console.log("Push after delay"); 146 | Parse.Cloud.run('pushdiscovery', {fromDevice: fromDevice, discoveredDevice: discoveredDevice}, { 147 | success: function(msg) { 148 | console.log(msg); 149 | }, 150 | error: function(error) { 151 | console.error(error); 152 | } 153 | }); 154 | } 155 | 156 | // Push by a discovery 157 | Parse.Cloud.define("pushdiscovery", function(request, response) { 158 | const interval = 2 * 60 * 1000; // 2 mins 159 | var discoveryQuery = new Parse.Query("Discovery"); 160 | var fromDevice = new Parse.Installation(); 161 | fromDevice.id = request.params.fromDevice; 162 | discoveryQuery.equalTo("fromDevice", fromDevice); 163 | var discoveredDevice = new Parse.Installation(); 164 | discoveredDevice.id = request.params.discoveredDevice; 165 | discoveryQuery.equalTo("discoveredDevice", discoveredDevice); 166 | discoveryQuery.equalTo("pushed", true); 167 | var d = new Date(); 168 | var timeNow = d.getTime(); 169 | var timeThen = timeNow - interval; 170 | var queryDate = new Date(); 171 | queryDate.setTime(timeThen); 172 | discoveryQuery.greaterThanOrEqualTo("updatedAt", queryDate); 173 | discoveryQuery.find({ 174 | success: function(results) { 175 | if(results.length > 0) { 176 | response.error("It has already been pushed"); 177 | } else { 178 | var usernameQuery = new Parse.Query(Parse.Installation); 179 | usernameQuery.get(request.params.discoveredDevice, { // query username by installation's user 180 | success: function(installation) { 181 | var user = installation.get("user"); 182 | user.fetch({ 183 | success: function(user) { 184 | var username = user.get("username"); 185 | Parse.Cloud.run('pushdevice', {objectId: request.params.fromDevice, message: 'Hi I\'m ' + username}, { 186 | success: function(msg) { 187 | response.success(msg); 188 | }, 189 | error: function(error) { 190 | response.error(error); 191 | } 192 | }); 193 | }, error: function(error) { 194 | response.error(error); 195 | } 196 | }); 197 | }, 198 | error: function(object, error) { 199 | response.error(error); 200 | } 201 | }); 202 | } 203 | }, 204 | error: function(error) { 205 | response.error(error); 206 | } 207 | }); 208 | }); 209 | 210 | // Push to a specific device 211 | Parse.Cloud.define("pushdevice", function(request, response) { 212 | var pushQuery = new Parse.Query(Parse.Installation); 213 | pushQuery.equalTo('objectId', request.params.objectId); 214 | 215 | // Send push notification to query 216 | Parse.Push.send({ 217 | where: pushQuery, 218 | data: { 219 | alert: request.params.message 220 | } 221 | }, { 222 | success: function() { 223 | response.success("Push sent successfully"); 224 | }, 225 | error: function(error) { 226 | response.error(error); 227 | } 228 | }); 229 | }); 230 | 231 | // Push to a specific user 232 | Parse.Cloud.define("pushuser", function(request, response) { 233 | // Find users near a given location 234 | var userQuery = new Parse.Query(Parse.User); 235 | userQuery.equalTo("username", request.params.username); 236 | 237 | // Find devices associated with these users 238 | var pushQuery = new Parse.Query(Parse.Installation); 239 | pushQuery.matchesQuery('user', userQuery); 240 | 241 | // Send push notification to query 242 | Parse.Push.send({ 243 | where: pushQuery, 244 | data: request.params.message 245 | }, { 246 | success: function() { 247 | response.success("Push sent successfully"); 248 | }, 249 | error: function(error) { 250 | response.error(error); 251 | } 252 | }); 253 | }); 254 | 255 | 256 | // Push to all iOS users 257 | Parse.Cloud.define("pushios", function(request, response) { 258 | // Notification for iOS users 259 | var queryIOS = new Parse.Query(Parse.Installation); 260 | queryIOS.equalTo('deviceType', 'ios'); 261 | 262 | Parse.Push.send({ 263 | where: queryIOS, 264 | data: { 265 | alert: request.params.message 266 | } 267 | }); 268 | }); 269 | -------------------------------------------------------------------------------- /CloudCode/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My ParseApp site 5 | 13 | 14 | 15 |
16 |

Congratulations! You're already hosting with Parse.

17 |

To get started, edit this file at public/index.html and start adding static content.

18 |

If you want something a bit more dynamic, delete this file and check out our hosting docs.

19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFAnalytics.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFAnalytics.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #if TARGET_OS_IPHONE 10 | #import 11 | #else 12 | #import 13 | #endif 14 | 15 | PF_ASSUME_NONNULL_BEGIN 16 | 17 | @class BFTask; 18 | 19 | /*! 20 | `PFAnalytics` provides an interface to Parse's logging and analytics backend. 21 | 22 | Methods will return immediately and cache the request (+ timestamp) to be 23 | handled "eventually." That is, the request will be sent immediately if possible 24 | or the next time a network connection is available. 25 | */ 26 | @interface PFAnalytics : NSObject 27 | 28 | ///-------------------------------------- 29 | /// @name App-Open / Push Analytics 30 | ///-------------------------------------- 31 | 32 | /*! 33 | @abstract Tracks this application being launched. If this happened as the result of the 34 | user opening a push notification, this method sends along information to 35 | correlate this open with that push. 36 | 37 | @discussion Pass in `nil` to track a standard "application opened" event. 38 | 39 | @param launchOptions The `NSDictionary` indicating the reason the application was 40 | launched, if any. This value can be found as a parameter to various 41 | `UIApplicationDelegate` methods, and can be empty or `nil`. 42 | 43 | @returns Returns the task encapsulating the work being done. 44 | */ 45 | + (BFTask *)trackAppOpenedWithLaunchOptions:(PF_NULLABLE NSDictionary *)launchOptions; 46 | 47 | /*! 48 | @abstract Tracks this application being launched. 49 | If this happened as the result of the user opening a push notification, 50 | this method sends along information to correlate this open with that push. 51 | 52 | @discussion Pass in `nil` to track a standard "application opened" event. 53 | 54 | @param launchOptions The dictionary indicating the reason the application was 55 | launched, if any. This value can be found as a parameter to various 56 | `UIApplicationDelegate` methods, and can be empty or `nil`. 57 | @param block The block to execute on server response. 58 | It should have the following argument signature: `^(BOOL succeeded, NSError *error)` 59 | */ 60 | + (void)trackAppOpenedWithLaunchOptionsInBackground:(PF_NULLABLE NSDictionary *)launchOptions 61 | block:(PF_NULLABLE PFBooleanResultBlock)block; 62 | 63 | /*! 64 | @abstract Tracks this application being launched. If this happened as the result of the 65 | user opening a push notification, this method sends along information to 66 | correlate this open with that push. 67 | 68 | @param userInfo The Remote Notification payload, if any. This value can be 69 | found either under `UIApplicationLaunchOptionsRemoteNotificationKey` on `launchOptions`, 70 | or as a parameter to `application:didReceiveRemoteNotification:`. 71 | This can be empty or `nil`. 72 | 73 | @returns Returns the task encapsulating the work being done. 74 | */ 75 | + (BFTask *)trackAppOpenedWithRemoteNotificationPayload:(PF_NULLABLE NSDictionary *)userInfo; 76 | 77 | /*! 78 | @abstract Tracks this application being launched. If this happened as the result of the 79 | user opening a push notification, this method sends along information to 80 | correlate this open with that push. 81 | 82 | @param userInfo The Remote Notification payload, if any. This value can be 83 | found either under `UIApplicationLaunchOptionsRemoteNotificationKey` on `launchOptions`, 84 | or as a parameter to `application:didReceiveRemoteNotification:`. This can be empty or `nil`. 85 | @param block The block to execute on server response. 86 | It should have the following argument signature: `^(BOOL succeeded, NSError *error)` 87 | */ 88 | + (void)trackAppOpenedWithRemoteNotificationPayloadInBackground:(PF_NULLABLE NSDictionary *)userInfo 89 | block:(PF_NULLABLE PFBooleanResultBlock)block; 90 | 91 | ///-------------------------------------- 92 | /// @name Custom Analytics 93 | ///-------------------------------------- 94 | 95 | /*! 96 | @abstract Tracks the occurrence of a custom event. 97 | 98 | @discussion Parse will store a data point at the time of invocation with the given event name. 99 | 100 | @param name The name of the custom event to report to Parse as having happened. 101 | 102 | @returns Returns the task encapsulating the work being done. 103 | */ 104 | + (BFTask *)trackEvent:(NSString *)name; 105 | 106 | /*! 107 | @abstract Tracks the occurrence of a custom event. Parse will store a data point at the 108 | time of invocation with the given event name. The event will be sent at some 109 | unspecified time in the future, even if Parse is currently inaccessible. 110 | 111 | @param name The name of the custom event to report to Parse as having happened. 112 | @param block The block to execute on server response. 113 | It should have the following argument signature: `^(BOOL succeeded, NSError *error)` 114 | */ 115 | + (void)trackEventInBackground:(NSString *)name block:(PF_NULLABLE PFBooleanResultBlock)block; 116 | 117 | /*! 118 | @abstract Tracks the occurrence of a custom event with additional dimensions. Parse will 119 | store a data point at the time of invocation with the given event name. 120 | 121 | @discussion Dimensions will allow segmentation of the occurrences of this custom event. 122 | Keys and values should be NSStrings, and will throw otherwise. 123 | 124 | To track a user signup along with additional metadata, consider the following: 125 | 126 | NSDictionary *dimensions = @{ @"gender": @"m", 127 | @"source": @"web", 128 | @"dayType": @"weekend" }; 129 | [PFAnalytics trackEvent:@"signup" dimensions:dimensions]; 130 | 131 | @warning There is a default limit of 8 dimensions per event tracked. 132 | 133 | @param name The name of the custom event to report to Parse as having happened. 134 | @param dimensions The `NSDictionary` of information by which to segment this event. 135 | 136 | @returns Returns the task encapsulating the work being done. 137 | */ 138 | + (BFTask *)trackEvent:(NSString *)name dimensions:(PF_NULLABLE NSDictionary *)dimensions; 139 | 140 | /*! 141 | @abstract Tracks the occurrence of a custom event with additional dimensions. Parse will 142 | store a data point at the time of invocation with the given event name. The 143 | event will be sent at some unspecified time in the future, even if Parse is currently inaccessible. 144 | 145 | @discussionDimensions will allow segmentation of the occurrences of this custom event. 146 | Keys and values should be NSStrings, and will throw otherwise. 147 | 148 | To track a user signup along with additional metadata, consider the following: 149 | NSDictionary *dimensions = @{ @"gender": @"m", 150 | @"source": @"web", 151 | @"dayType": @"weekend" }; 152 | [PFAnalytics trackEvent:@"signup" dimensions:dimensions]; 153 | 154 | There is a default limit of 8 dimensions per event tracked. 155 | 156 | @param name The name of the custom event to report to Parse as having happened. 157 | @param dimensions The `NSDictionary` of information by which to segment this event. 158 | @param block The block to execute on server response. 159 | It should have the following argument signature: `^(BOOL succeeded, NSError *error)` 160 | */ 161 | + (void)trackEventInBackground:(NSString *)name 162 | dimensions:(PF_NULLABLE NSDictionary *)dimensions 163 | block:(PF_NULLABLE PFBooleanResultBlock)block; 164 | 165 | @end 166 | 167 | PF_ASSUME_NONNULL_END 168 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFAnonymousUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFAnonymousUtils.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #if TARGET_OS_IPHONE 10 | #import 11 | #import 12 | #else 13 | #import 14 | #import 15 | #endif 16 | 17 | PF_ASSUME_NONNULL_BEGIN 18 | 19 | /*! 20 | Provides utility functions for working with Anonymously logged-in users. 21 | Anonymous users have some unique characteristics: 22 | 23 | - Anonymous users don't need a user name or password. 24 | - Once logged out, an anonymous user cannot be recovered. 25 | - When the current user is anonymous, the following methods can be used to switch 26 | to a different user or convert the anonymous user into a regular one: 27 | - signUp converts an anonymous user to a standard user with the given username and password. 28 | Data associated with the anonymous user is retained. 29 | - logIn switches users without converting the anonymous user. 30 | Data associated with the anonymous user will be lost. 31 | - Service logIn (e.g. Facebook, Twitter) will attempt to convert 32 | the anonymous user into a standard user by linking it to the service. 33 | If a user already exists that is linked to the service, it will instead switch to the existing user. 34 | - Service linking (e.g. Facebook, Twitter) will convert the anonymous user 35 | into a standard user by linking it to the service. 36 | */ 37 | @interface PFAnonymousUtils : NSObject 38 | 39 | ///-------------------------------------- 40 | /// @name Creating an Anonymous User 41 | ///-------------------------------------- 42 | 43 | /*! 44 | @abstract Creates an anonymous user asynchronously and sets as a result to `BFTask`. 45 | 46 | @returns The task, that encapsulates the work being done. 47 | */ 48 | + (BFTask *)logInInBackground; 49 | 50 | /*! 51 | @abstract Creates an anonymous user. 52 | 53 | @param block The block to execute when anonymous user creation is complete. 54 | It should have the following argument signature: `^(PFUser *user, NSError *error)`. 55 | */ 56 | + (void)logInWithBlock:(PF_NULLABLE PFUserResultBlock)block; 57 | 58 | /* 59 | @abstract Creates an anonymous user. 60 | 61 | @param target Target object for the selector. 62 | @param selector The selector that will be called when the asynchronous request is complete. 63 | It should have the following signature: `(void)callbackWithUser:(PFUser *)user error:(NSError *)error`. 64 | */ 65 | + (void)logInWithTarget:(PF_NULLABLE_S id)target selector:(PF_NULLABLE_S SEL)selector; 66 | 67 | ///-------------------------------------- 68 | /// @name Determining Whether a User is Anonymous 69 | ///-------------------------------------- 70 | 71 | /*! 72 | @abstract Whether the object is logged in anonymously. 73 | 74 | @param user object to check for anonymity. The user must be logged in on this device. 75 | 76 | @returns `YES` if the user is anonymous. `NO` if the user is not the current user or is not anonymous. 77 | */ 78 | + (BOOL)isLinkedWithUser:(PF_NULLABLE PFUser *)user; 79 | 80 | @end 81 | 82 | PF_ASSUME_NONNULL_END 83 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFCloud.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFCloud.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #if TARGET_OS_IPHONE 10 | #import 11 | #else 12 | #import 13 | #endif 14 | 15 | PF_ASSUME_NONNULL_BEGIN 16 | 17 | @class BFTask; 18 | 19 | /*! 20 | The `PFCloud` class provides methods for interacting with Parse Cloud Functions. 21 | */ 22 | @interface PFCloud : NSObject 23 | 24 | /*! 25 | @abstract Calls the given cloud function *synchronously* with the parameters provided. 26 | 27 | @param function The function name to call. 28 | @param parameters The parameters to send to the function. 29 | 30 | @returns The response from the cloud function. 31 | */ 32 | + (PF_NULLABLE_S id)callFunction:(NSString *)function withParameters:(PF_NULLABLE NSDictionary *)parameters; 33 | 34 | /*! 35 | @abstract Calls the given cloud function *synchronously* with the parameters provided and 36 | sets the error if there is one. 37 | 38 | @param function The function name to call. 39 | @param parameters The parameters to send to the function. 40 | @param error Pointer to an `NSError` that will be set if necessary. 41 | 42 | @returns The response from the cloud function. 43 | This result could be a `NSDictionary`, an `NSArray`, `NSNumber` or `NSString`. 44 | */ 45 | + (PF_NULLABLE_S id)callFunction:(NSString *)function 46 | withParameters:(PF_NULLABLE NSDictionary *)parameters 47 | error:(NSError **)error; 48 | 49 | /*! 50 | @abstract Calls the given cloud function *asynchronously* with the parameters provided. 51 | 52 | @param function The function name to call. 53 | @param parameters The parameters to send to the function. 54 | 55 | @returns The task, that encapsulates the work being done. 56 | */ 57 | + (BFTask *)callFunctionInBackground:(NSString *)function 58 | withParameters:(PF_NULLABLE NSDictionary *)parameters; 59 | 60 | /*! 61 | @abstract Calls the given cloud function *asynchronously* with the parameters provided 62 | and executes the given block when it is done. 63 | 64 | @param function The function name to call. 65 | @param parameters The parameters to send to the function. 66 | @param block The block to execute when the function call finished. 67 | It should have the following argument signature: `^(id result, NSError *error)`. 68 | */ 69 | + (void)callFunctionInBackground:(NSString *)function 70 | withParameters:(PF_NULLABLE NSDictionary *)parameters 71 | block:(PF_NULLABLE PFIdResultBlock)block; 72 | 73 | /* 74 | @abstract Calls the given cloud function *asynchronously* with the parameters provided 75 | and then executes the given selector when it is done. 76 | 77 | @param function The function name to call. 78 | @param parameters The parameters to send to the function. 79 | @param target The object to call the selector on. 80 | @param selector The selector to call when the function call finished. 81 | It should have the following signature: `(void)callbackWithResult:(id)result error:(NSError *)error`. 82 | Result will be `nil` if error is set and vice versa. 83 | */ 84 | + (void)callFunctionInBackground:(NSString *)function 85 | withParameters:(PF_NULLABLE NSDictionary *)parameters 86 | target:(PF_NULLABLE_S id)target 87 | selector:(PF_NULLABLE_S SEL)selector; 88 | 89 | @end 90 | 91 | PF_ASSUME_NONNULL_END 92 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFConfig.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #if TARGET_OS_IPHONE 10 | #import 11 | #else 12 | #import 13 | #endif 14 | 15 | PF_ASSUME_NONNULL_BEGIN 16 | 17 | @class BFTask; 18 | @class PFConfig; 19 | 20 | typedef void(^PFConfigResultBlock)(PF_NULLABLE_S PFConfig *config, PF_NULLABLE_S NSError *error); 21 | 22 | /*! 23 | `PFConfig` is a representation of the remote configuration object. 24 | It enables you to add things like feature gating, a/b testing or simple "Message of the day". 25 | */ 26 | @interface PFConfig : NSObject 27 | 28 | ///-------------------------------------- 29 | /// @name Current Config 30 | ///-------------------------------------- 31 | 32 | /*! 33 | @abstract Returns the most recently fetched config. 34 | 35 | @discussion If there was no config fetched - this method will return an empty instance of `PFConfig`. 36 | 37 | @returns Current, last fetched instance of PFConfig. 38 | */ 39 | + (PFConfig *)currentConfig; 40 | 41 | ///-------------------------------------- 42 | /// @name Retrieving Config 43 | ///-------------------------------------- 44 | 45 | /*! 46 | @abstract Gets the `PFConfig` object *synchronously* from the server. 47 | 48 | @returns Instance of `PFConfig` if the operation succeeded, otherwise `nil`. 49 | */ 50 | + (PF_NULLABLE PFConfig *)getConfig; 51 | 52 | /*! 53 | @abstract Gets the `PFConfig` object *synchronously* from the server and sets an error if it occurs. 54 | 55 | @param error Pointer to an `NSError` that will be set if necessary. 56 | 57 | @returns Instance of PFConfig if the operation succeeded, otherwise `nil`. 58 | */ 59 | + (PF_NULLABLE PFConfig *)getConfig:(NSError **)error; 60 | 61 | /*! 62 | @abstract Gets the `PFConfig` *asynchronously* and sets it as a result of a task. 63 | 64 | @returns The task, that encapsulates the work being done. 65 | */ 66 | + (BFTask *)getConfigInBackground; 67 | 68 | /*! 69 | @abstract Gets the `PFConfig` *asynchronously* and executes the given callback block. 70 | 71 | @param block The block to execute. 72 | It should have the following argument signature: `^(PFConfig *config, NSError *error)`. 73 | */ 74 | + (void)getConfigInBackgroundWithBlock:(PF_NULLABLE PFConfigResultBlock)block; 75 | 76 | ///-------------------------------------- 77 | /// @name Parameters 78 | ///-------------------------------------- 79 | 80 | /*! 81 | @abstract Returns the object associated with a given key. 82 | 83 | @param key The key for which to return the corresponding configuration value. 84 | 85 | @returns The value associated with `key`, or `nil` if there is no such value. 86 | */ 87 | - (PF_NULLABLE_S id)objectForKey:(NSString *)key; 88 | 89 | /*! 90 | @abstract Returns the object associated with a given key. 91 | 92 | @discussion This method enables usage of literal syntax on `PFConfig`. 93 | E.g. `NSString *value = config[@"key"];` 94 | 95 | @see objectForKey: 96 | 97 | @param keyedSubscript The keyed subscript for which to return the corresponding configuration value. 98 | 99 | @returns The value associated with `key`, or `nil` if there is no such value. 100 | */ 101 | - (PF_NULLABLE_S id)objectForKeyedSubscript:(NSString *)keyedSubscript; 102 | 103 | @end 104 | 105 | PF_ASSUME_NONNULL_END 106 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFGeoPoint.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFGeoPoint.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | #import 9 | 10 | #if TARGET_OS_IPHONE 11 | #import 12 | #else 13 | #import 14 | #endif 15 | 16 | PF_ASSUME_NONNULL_BEGIN 17 | 18 | @class PFGeoPoint; 19 | 20 | typedef void(^PFGeoPointResultBlock)(PF_NULLABLE_S PFGeoPoint *geoPoint, PF_NULLABLE_S NSError *error); 21 | 22 | /*! 23 | `PFGeoPoint` may be used to embed a latitude / longitude point as the value for a key in a . 24 | It could be used to perform queries in a geospatial manner using <[PFQuery whereKey:nearGeoPoint:]>. 25 | 26 | Currently, instances of may only have one key associated with a `PFGeoPoint` type. 27 | */ 28 | @interface PFGeoPoint : NSObject 29 | 30 | ///-------------------------------------- 31 | /// @name Creating a Geo Point 32 | ///-------------------------------------- 33 | 34 | /*! 35 | @abstract Create a PFGeoPoint object. Latitude and longitude are set to `0.0`. 36 | 37 | @returns Returns a new `PFGeoPoint`. 38 | */ 39 | + (PFGeoPoint *)geoPoint; 40 | 41 | /*! 42 | @abstract Creates a new `PFGeoPoint` object for the given `CLLocation`, set to the location's coordinates. 43 | 44 | @param location Instace of `CLLocation`, with set latitude and longitude. 45 | 46 | @returns Returns a new PFGeoPoint at specified location. 47 | */ 48 | + (PFGeoPoint *)geoPointWithLocation:(PF_NULLABLE CLLocation *)location; 49 | 50 | /*! 51 | @abstract Create a new `PFGeoPoint` object with the specified latitude and longitude. 52 | 53 | @param latitude Latitude of point in degrees. 54 | @param longitude Longitude of point in degrees. 55 | 56 | @returns New point object with specified latitude and longitude. 57 | */ 58 | + (PFGeoPoint *)geoPointWithLatitude:(double)latitude longitude:(double)longitude; 59 | 60 | /*! 61 | @abstract Fetches the current device location and executes a block with a new `PFGeoPoint` object. 62 | 63 | @param geoPointHandler A block which takes the newly created `PFGeoPoint` as an argument. 64 | It should have the following argument signature: `^(PFGeoPoint *geoPoint, NSError *error)` 65 | */ 66 | + (void)geoPointForCurrentLocationInBackground:(PF_NULLABLE PFGeoPointResultBlock)geoPointHandler; 67 | 68 | ///-------------------------------------- 69 | /// @name Controlling Position 70 | ///-------------------------------------- 71 | 72 | /*! 73 | @abstract Latitude of point in degrees. Valid range is from `-90.0` to `90.0`. 74 | */ 75 | @property (nonatomic, assign) double latitude; 76 | 77 | /*! 78 | @abstract Longitude of point in degrees. Valid range is from `-180.0` to `180.0`. 79 | */ 80 | @property (nonatomic, assign) double longitude; 81 | 82 | ///-------------------------------------- 83 | /// @name Calculating Distance 84 | ///-------------------------------------- 85 | 86 | /*! 87 | @abstract Get distance in radians from this point to specified point. 88 | 89 | @param point `PFGeoPoint` that represents the location of other point. 90 | 91 | @returns Distance in radians between the receiver and `point`. 92 | */ 93 | - (double)distanceInRadiansTo:(PF_NULLABLE PFGeoPoint *)point; 94 | 95 | /*! 96 | @abstract Get distance in miles from this point to specified point. 97 | 98 | @param point `PFGeoPoint` that represents the location of other point. 99 | 100 | @returns Distance in miles between the receiver and `point`. 101 | */ 102 | - (double)distanceInMilesTo:(PF_NULLABLE PFGeoPoint *)point; 103 | 104 | /*! 105 | @abstract Get distance in kilometers from this point to specified point. 106 | 107 | @param point `PFGeoPoint` that represents the location of other point. 108 | 109 | @returns Distance in kilometers between the receiver and `point`. 110 | */ 111 | - (double)distanceInKilometersTo:(PF_NULLABLE PFGeoPoint *)point; 112 | 113 | @end 114 | 115 | PF_ASSUME_NONNULL_END 116 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFInstallation.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFInstallation.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | PF_ASSUME_NONNULL_BEGIN 14 | 15 | /*! 16 | A Parse Framework Installation Object that is a local representation of an 17 | installation persisted to the Parse cloud. This class is a subclass of a 18 | , and retains the same functionality of a PFObject, but also extends 19 | it with installation-specific fields and related immutability and validity 20 | checks. 21 | 22 | A valid `PFInstallation` can only be instantiated via 23 | <[PFInstallation currentInstallation]> because the required identifier fields 24 | are readonly. The and fields are also readonly properties which 25 | are automatically updated to match the device's time zone and application badge 26 | when the `PFInstallation` is saved, thus these fields might not reflect the 27 | latest device state if the installation has not recently been saved. 28 | 29 | `PFInstallation` objects which have a valid and are saved to 30 | the Parse cloud can be used to target push notifications. 31 | 32 | This class is currently for iOS only. There is no `PFInstallation` for Parse 33 | applications running on OS X, because they cannot receive push notifications. 34 | */ 35 | 36 | @interface PFInstallation : PFObject 37 | 38 | /*! 39 | @abstract The name of the Installation class in the REST API. 40 | 41 | @discussion This is a required PFSubclassing method. 42 | */ 43 | + (NSString *)parseClassName; 44 | 45 | ///-------------------------------------- 46 | /// @name Targeting Installations 47 | ///-------------------------------------- 48 | 49 | /*! 50 | @abstract Creates a for `PFInstallation` objects. 51 | 52 | @discussion The resulting query can only be used for targeting a . 53 | Calling find methods on the resulting query will raise an exception. 54 | */ 55 | + (PF_NULLABLE PFQuery *)query; 56 | 57 | ///-------------------------------------- 58 | /// @name Accessing the Current Installation 59 | ///-------------------------------------- 60 | 61 | /*! 62 | @abstract Gets the currently-running installation from disk and returns an instance of it. 63 | 64 | @discussion If this installation is not stored on disk, returns a `PFInstallation` 65 | with and fields set to those of the 66 | current installation. 67 | 68 | @result Returns a `PFInstallation` that represents the currently-running installation. 69 | */ 70 | + (instancetype)currentInstallation; 71 | 72 | /*! 73 | @abstract Sets the device token string property from an `NSData`-encoded token. 74 | 75 | @param deviceTokenData A token that identifies the device. 76 | */ 77 | - (void)setDeviceTokenFromData:(PF_NULLABLE NSData *)deviceTokenData; 78 | 79 | ///-------------------------------------- 80 | /// @name Installation Properties 81 | ///-------------------------------------- 82 | 83 | /*! 84 | @abstract The device type for the `PFInstallation`. 85 | */ 86 | @property (nonatomic, strong, readonly) NSString *deviceType; 87 | 88 | /*! 89 | @abstract The installationId for the `PFInstallation`. 90 | */ 91 | @property (nonatomic, strong, readonly) NSString *installationId; 92 | 93 | /*! 94 | @abstract The device token for the `PFInstallation`. 95 | */ 96 | @property (PF_NULLABLE_PROPERTY nonatomic, strong) NSString *deviceToken; 97 | 98 | /*! 99 | @abstract The badge for the `PFInstallation`. 100 | */ 101 | @property (nonatomic, assign) NSInteger badge; 102 | 103 | /*! 104 | @abstract The name of the time zone for the `PFInstallation`. 105 | */ 106 | @property (PF_NULLABLE_PROPERTY nonatomic, strong, readonly) NSString *timeZone; 107 | 108 | /*! 109 | @abstract The channels for the `PFInstallation`. 110 | */ 111 | @property (PF_NULLABLE_PROPERTY nonatomic, strong) NSArray *channels; 112 | 113 | @end 114 | 115 | PF_ASSUME_NONNULL_END 116 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFNetworkActivityIndicatorManager.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #import 10 | 11 | PF_ASSUME_NONNULL_BEGIN 12 | 13 | /*! 14 | `PFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. 15 | When enabled, it will start managing the network activity indicator in the status bar, 16 | according to the network operations that are performed by Parse SDK. 17 | 18 | The number of active requests is incremented or decremented like a stack or a semaphore, 19 | the activity indicator will animate, as long as the number is greater than zero. 20 | */ 21 | @interface PFNetworkActivityIndicatorManager : NSObject 22 | 23 | /*! 24 | A Boolean value indicating whether the manager is enabled. 25 | If `YES` - the manager will start managing the status bar network activity indicator, 26 | according to the network operations that are performed by Parse SDK. 27 | The default value is `YES`. 28 | */ 29 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 30 | 31 | /*! 32 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. 33 | */ 34 | @property (nonatomic, assign, readonly, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 35 | 36 | /*! 37 | The value that indicates current network activities count. 38 | */ 39 | @property (nonatomic, assign, readonly) NSUInteger networkActivityCount; 40 | 41 | /*! 42 | @abstract Returns the shared network activity indicator manager object for the system. 43 | 44 | @returns The systemwide network activity indicator manager. 45 | */ 46 | + (instancetype)sharedManager; 47 | 48 | /*! 49 | @abstract Increments the number of active network requests. 50 | 51 | @discussion If this number was zero before incrementing, 52 | this will start animating network activity indicator in the status bar. 53 | */ 54 | - (void)incrementActivityCount; 55 | 56 | /*! 57 | @abstract Decrements the number of active network requests. 58 | 59 | @discussion If this number becomes zero after decrementing, 60 | this will stop animating network activity indicator in the status bar. 61 | */ 62 | - (void)decrementActivityCount; 63 | 64 | @end 65 | 66 | PF_ASSUME_NONNULL_END 67 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFNullability.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFNullability.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #ifndef Parse_PFNullability_h 8 | #define Parse_PFNullability_h 9 | 10 | ///-------------------------------------- 11 | /// @name Nullability Annotation Support 12 | ///-------------------------------------- 13 | 14 | #if __has_feature(nullability) 15 | # define PF_NONNULL nonnull 16 | # define PF_NONNULL_S __nonnull 17 | # define PF_NULLABLE nullable 18 | # define PF_NULLABLE_S __nullable 19 | # define PF_NULLABLE_PROPERTY nullable, 20 | #else 21 | # define PF_NONNULL 22 | # define PF_NONNULL_S 23 | # define PF_NULLABLE 24 | # define PF_NULLABLE_S 25 | # define PF_NULLABLE_PROPERTY 26 | #endif 27 | 28 | #if __has_feature(assume_nonnull) 29 | # ifdef NS_ASSUME_NONNULL_BEGIN 30 | # define PF_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN 31 | # else 32 | # define PF_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") 33 | # endif 34 | # ifdef NS_ASSUME_NONNULL_END 35 | # define PF_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END 36 | # else 37 | # define PF_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") 38 | # endif 39 | #else 40 | # define PF_ASSUME_NONNULL_BEGIN 41 | # define PF_ASSUME_NONNULL_END 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFObject+Subclass.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFObject+Subclass.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #if TARGET_OS_IPHONE 10 | #import 11 | #else 12 | #import 13 | #endif 14 | 15 | @class PFQuery; 16 | 17 | /*! 18 | ### Subclassing Notes 19 | 20 | Developers can subclass `PFObject` for a more native object-oriented class structure. 21 | Strongly-typed subclasses of `PFObject` must conform to the protocol 22 | and must call before <[Parse setApplicationId:clientKey:]> is called. 23 | After this it will be returned by and other `PFObject` factories. 24 | 25 | All methods in except for <[PFSubclassing parseClassName]> 26 | are already implemented in the `PFObject+Subclass` category. 27 | 28 | Including `PFObject+Subclass.h` in your implementation file provides these implementations automatically. 29 | 30 | Subclasses support simpler initializers, query syntax, and dynamic synthesizers. 31 | The following shows an example subclass: 32 | 33 | \@interface MYGame : PFObject 34 | 35 | // Accessing this property is the same as objectForKey:@"title" 36 | @property (nonatomic, strong) NSString *title; 37 | 38 | + (NSString *)parseClassName; 39 | 40 | @end 41 | 42 | 43 | @implementation MYGame 44 | 45 | @dynamic title; 46 | 47 | + (NSString *)parseClassName { 48 | return @"Game"; 49 | } 50 | 51 | @end 52 | 53 | 54 | MYGame *game = [[MYGame alloc] init]; 55 | game.title = @"Bughouse"; 56 | [game saveInBackground]; 57 | */ 58 | @interface PFObject (Subclass) 59 | 60 | ///-------------------------------------- 61 | /// @name Methods for Subclasses 62 | ///-------------------------------------- 63 | 64 | /*! 65 | @abstract Designated initializer for subclasses. 66 | This method can only be called on subclasses which conform to . 67 | This method should not be overridden. 68 | */ 69 | - (instancetype)init; 70 | 71 | /*! 72 | @abstract Creates an instance of the registered subclass with this class's . 73 | 74 | @discussion This helps a subclass ensure that it can be subclassed itself. 75 | For example, `[PFUser object]` will return a `MyUser` object if `MyUser` is a registered subclass of `PFUser`. 76 | For this reason, `[MyClass object]` is preferred to `[[MyClass alloc] init]`. 77 | This method can only be called on subclasses which conform to `PFSubclassing`. 78 | A default implementation is provided by `PFObject` which should always be sufficient. 79 | */ 80 | + (instancetype)object; 81 | 82 | /*! 83 | @abstract Creates a reference to an existing `PFObject` for use in creating associations between `PFObjects`. 84 | 85 | @discussion Calling on this object will return `NO` until or has been called. 86 | This method can only be called on subclasses which conform to . 87 | A default implementation is provided by `PFObject` which should always be sufficient. 88 | No network request will be made. 89 | 90 | @param objectId The object id for the referenced object. 91 | 92 | @returns An instance of `PFObject` without data. 93 | */ 94 | + (instancetype)objectWithoutDataWithObjectId:(NSString *)objectId; 95 | 96 | /*! 97 | @abstract Registers an Objective-C class for Parse to use for representing a given Parse class. 98 | 99 | @discussion Once this is called on a `PFObject` subclass, any `PFObject` Parse creates with a class name 100 | that matches `[self parseClassName]` will be an instance of subclass. 101 | This method can only be called on subclasses which conform to . 102 | A default implementation is provided by `PFObject` which should always be sufficient. 103 | */ 104 | + (void)registerSubclass; 105 | 106 | /*! 107 | @abstract Returns a query for objects of type . 108 | 109 | @discussion This method can only be called on subclasses which conform to . 110 | A default implementation is provided by which should always be sufficient. 111 | */ 112 | + (PFQuery *)query; 113 | 114 | /*! 115 | @abstract Returns a query for objects of type with a given predicate. 116 | 117 | @discussion A default implementation is provided by which should always be sufficient. 118 | @warning This method can only be called on subclasses which conform to . 119 | 120 | @param predicate The predicate to create conditions from. 121 | 122 | @returns An instance of . 123 | 124 | @see [PFQuery queryWithClassName:predicate:] 125 | */ 126 | + (PFQuery *)queryWithPredicate:(NSPredicate *)predicate; 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFProduct.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFProduct.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | #import 9 | #import 10 | #import 11 | 12 | PF_ASSUME_NONNULL_BEGIN 13 | 14 | /*! 15 | The `PFProduct` class represents an in-app purchase product on the Parse server. 16 | By default, products can only be created via the Data Browser. Saving a `PFProduct` will result in error. 17 | However, the products' metadata information can be queried and viewed. 18 | 19 | This class is currently for iOS only. 20 | */ 21 | @interface PFProduct : PFObject 22 | 23 | /*! 24 | @abstract The name of the Installation class in the REST API. 25 | 26 | @discussion This is a required PFSubclassing method. 27 | */ 28 | + (NSString *)parseClassName; 29 | 30 | ///-------------------------------------- 31 | /// @name Querying for Products 32 | ///-------------------------------------- 33 | 34 | /*! 35 | @abstract A that could be used to fetch all product instances from Parse. 36 | */ 37 | + (PF_NULLABLE PFQuery *)query; 38 | 39 | ///-------------------------------------- 40 | /// @name Product-specific Properties 41 | ///-------------------------------------- 42 | 43 | /*! 44 | @abstract The product identifier of the product. 45 | 46 | @discussion This should match the product identifier in iTunes Connect exactly. 47 | */ 48 | @property (PF_NULLABLE_PROPERTY nonatomic, strong) NSString *productIdentifier; 49 | 50 | /*! 51 | @abstract The icon of the product. 52 | */ 53 | @property (PF_NULLABLE_PROPERTY nonatomic, strong) PFFile *icon; 54 | 55 | /*! 56 | @abstract The title of the product. 57 | */ 58 | @property (PF_NULLABLE_PROPERTY nonatomic, strong) NSString *title; 59 | 60 | /*! 61 | @abstract The subtitle of the product. 62 | */ 63 | @property (PF_NULLABLE_PROPERTY nonatomic, strong) NSString *subtitle; 64 | 65 | /*! 66 | @abstract The order in which the product information is displayed in . 67 | 68 | @discussion The product with a smaller order is displayed earlier in the . 69 | */ 70 | @property (PF_NULLABLE_PROPERTY nonatomic, strong) NSNumber *order; 71 | 72 | /*! 73 | @abstract The name of the associated download. 74 | 75 | @discussion If there is no downloadable asset, it should be `nil`. 76 | */ 77 | @property (PF_NULLABLE_PROPERTY nonatomic, strong, readonly) NSString *downloadName; 78 | 79 | @end 80 | 81 | PF_ASSUME_NONNULL_END 82 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFPurchase.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFPurchase.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | #import 9 | 10 | #import 11 | 12 | @class PFProduct; 13 | 14 | /*! 15 | `PFPurchase` provides a set of APIs for working with in-app purchases. 16 | 17 | This class is currently for iOS only. 18 | */ 19 | @interface PFPurchase : NSObject 20 | 21 | /*! 22 | @abstract Add application logic block which is run when buying a product. 23 | 24 | @discussion This method should be called once for each product, and should be called before 25 | calling . All invocations to should happen within 26 | the same method, and on the main thread. It is recommended to place all invocations of this method 27 | in `application:didFinishLaunchingWithOptions:`. 28 | 29 | @param productIdentifier the product identifier 30 | @param block The block to be run when buying a product. 31 | */ 32 | + (void)addObserverForProduct:(NSString *)productIdentifier 33 | block:(void(^)(SKPaymentTransaction *transaction))block; 34 | 35 | /*! 36 | @abstract *Asynchronously* initiates the purchase for the product. 37 | 38 | @param productIdentifier the product identifier 39 | @param block the completion block. 40 | */ 41 | + (void)buyProduct:(NSString *)productIdentifier block:(void(^)(NSError *error))block; 42 | 43 | /*! 44 | @abstract *Asynchronously* download the purchased asset, which is stored on Parse's server. 45 | 46 | @discussion Parse verifies the receipt with Apple and delivers the content only if the receipt is valid. 47 | 48 | @param transaction the transaction, which contains the receipt. 49 | @param completion the completion block. 50 | */ 51 | + (void)downloadAssetForTransaction:(SKPaymentTransaction *)transaction 52 | completion:(void(^)(NSString *filePath, NSError *error))completion; 53 | 54 | /*! 55 | @abstract *Asynchronously* download the purchased asset, which is stored on Parse's server. 56 | 57 | @discussion Parse verifies the receipt with Apple and delivers the content only if the receipt is valid. 58 | 59 | @param transaction the transaction, which contains the receipt. 60 | @param completion the completion block. 61 | @param progress the progress block, which is called multiple times to reveal progress of the download. 62 | */ 63 | + (void)downloadAssetForTransaction:(SKPaymentTransaction *)transaction 64 | completion:(void(^)(NSString *filePath, NSError *error))completion 65 | progress:(PFProgressBlock)progress; 66 | 67 | /*! 68 | @abstract *Asynchronously* restore completed transactions for the current user. 69 | 70 | @discussion Only nonconsumable purchases are restored. If observers for the products have been added before 71 | calling this method, invoking the method reruns the application logic associated with the purchase. 72 | 73 | @warning This method is only important to developers who want to preserve purchase states across 74 | different installations of the same app. 75 | */ 76 | + (void)restore; 77 | 78 | /* 79 | @abstract Returns a content path of the asset of a product, if it was purchased and downloaded. 80 | 81 | @discussion To download and verify purchases use . 82 | 83 | @warning This method will return `nil`, if the purchase wasn't verified or if the asset was not downloaded. 84 | */ 85 | + (NSString *)assetContentPathForProduct:(PFProduct *)product; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFRelation.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFRelation.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #if TARGET_OS_IPHONE 10 | #import 11 | #import 12 | #import 13 | #else 14 | #import 15 | #import 16 | #import 17 | #endif 18 | 19 | PF_ASSUME_NONNULL_BEGIN 20 | 21 | /*! 22 | The `PFRelation` class that is used to access all of the children of a many-to-many relationship. 23 | Each instance of `PFRelation` is associated with a particular parent object and key. 24 | */ 25 | @interface PFRelation : NSObject 26 | 27 | /*! 28 | @abstract The name of the class of the target child objects. 29 | */ 30 | @property (nonatomic, strong) NSString *targetClass; 31 | 32 | ///-------------------------------------- 33 | /// @name Accessing Objects 34 | ///-------------------------------------- 35 | 36 | /*! 37 | @abstract Returns a object that can be used to get objects in this relation. 38 | */ 39 | - (PF_NULLABLE PFQuery *)query; 40 | 41 | ///-------------------------------------- 42 | /// @name Modifying Relations 43 | ///-------------------------------------- 44 | 45 | /*! 46 | @abstract Adds a relation to the passed in object. 47 | 48 | @param object A object to add relation to. 49 | */ 50 | - (void)addObject:(PFObject *)object; 51 | 52 | /*! 53 | @abstract Removes a relation to the passed in object. 54 | 55 | @param object A object to add relation to. 56 | */ 57 | - (void)removeObject:(PFObject *)object; 58 | 59 | @end 60 | 61 | PF_ASSUME_NONNULL_END 62 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFRole.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFRole.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #if TARGET_OS_IPHONE 10 | #import 11 | #import 12 | #import 13 | #else 14 | #import 15 | #import 16 | #import 17 | #endif 18 | 19 | PF_ASSUME_NONNULL_BEGIN 20 | 21 | /*! 22 | The `PFRole` class represents a Role on the Parse server. 23 | `PFRoles` represent groupings of objects for the purposes of granting permissions 24 | (e.g. specifying a for a ). 25 | Roles are specified by their sets of child users and child roles, 26 | all of which are granted any permissions that the parent role has. 27 | 28 | Roles must have a name (which cannot be changed after creation of the role), and must specify an ACL. 29 | */ 30 | @interface PFRole : PFObject 31 | 32 | ///-------------------------------------- 33 | /// @name Creating a New Role 34 | ///-------------------------------------- 35 | 36 | /*! 37 | @abstract Constructs a new `PFRole` with the given name. 38 | If no default ACL has been specified, you must provide an ACL for the role. 39 | 40 | @param name The name of the Role to create. 41 | */ 42 | - (instancetype)initWithName:(NSString *)name; 43 | 44 | /*! 45 | @abstract Constructs a new `PFRole` with the given name. 46 | 47 | @param name The name of the Role to create. 48 | @param acl The ACL for this role. Roles must have an ACL. 49 | */ 50 | - (instancetype)initWithName:(NSString *)name acl:(PF_NULLABLE PFACL *)acl; 51 | 52 | /*! 53 | @abstract Constructs a new `PFRole` with the given name. 54 | 55 | @discussion If no default ACL has been specified, you must provide an ACL for the role. 56 | 57 | @param name The name of the Role to create. 58 | */ 59 | + (instancetype)roleWithName:(NSString *)name; 60 | 61 | /*! 62 | @abstract Constructs a new `PFRole` with the given name. 63 | 64 | @param name The name of the Role to create. 65 | @param acl The ACL for this role. Roles must have an ACL. 66 | */ 67 | + (instancetype)roleWithName:(NSString *)name acl:(PF_NULLABLE PFACL *)acl; 68 | 69 | ///-------------------------------------- 70 | /// @name Role-specific Properties 71 | ///-------------------------------------- 72 | 73 | /*! 74 | @abstract Gets or sets the name for a role. 75 | 76 | @discussion This value must be set before the role has been saved to the server, 77 | and cannot be set once the role has been saved. 78 | 79 | @warning A role's name can only contain alphanumeric characters, `_`, `-`, and spaces. 80 | */ 81 | @property (nonatomic, copy) NSString *name; 82 | 83 | /*! 84 | @abstract Gets the for the objects that are direct children of this role. 85 | 86 | @discussion These users are granted any privileges that this role has been granted 87 | (e.g. read or write access through ACLs). You can add or remove users from 88 | the role through this relation. 89 | */ 90 | @property (nonatomic, strong, readonly) PFRelation *users; 91 | 92 | /*! 93 | @abstract Gets the for the `PFRole` objects that are direct children of this role. 94 | 95 | @discussion These roles' users are granted any privileges that this role has been granted 96 | (e.g. read or write access through ACLs). You can add or remove child roles 97 | from this role through this relation. 98 | */ 99 | @property (nonatomic, strong, readonly) PFRelation *roles; 100 | 101 | ///-------------------------------------- 102 | /// @name Querying for Roles 103 | ///-------------------------------------- 104 | 105 | /*! 106 | @abstract Creates a for `PFRole` objects. 107 | */ 108 | + (PF_NULLABLE PFQuery *)query; 109 | 110 | @end 111 | 112 | PF_ASSUME_NONNULL_END 113 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PFSubclassing.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFSubclassing.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | @class PFQuery; 10 | 11 | /*! 12 | If a subclass of conforms to `PFSubclassing` and calls , 13 | Parse framework will be able to use that class as the native class for a Parse cloud object. 14 | 15 | Classes conforming to this protocol should subclass and 16 | include `PFObject+Subclass.h` in their implementation file. 17 | This ensures the methods in the Subclass category of are exposed in its subclasses only. 18 | */ 19 | @protocol PFSubclassing 20 | 21 | /*! 22 | @abstract Constructs an object of the most specific class known to implement . 23 | 24 | @discussion This method takes care to help subclasses be subclassed themselves. 25 | For example, `[PFUser object]` returns a by default but will return an 26 | object of a registered subclass instead if one is known. 27 | A default implementation is provided by which should always be sufficient. 28 | 29 | @returns Returns the object that is instantiated. 30 | */ 31 | + (instancetype)object; 32 | 33 | /*! 34 | @abstract Creates a reference to an existing PFObject for use in creating associations between PFObjects. 35 | 36 | @discussion Calling <[PFObject isDataAvailable]> on this object will return `NO` 37 | until <[PFObject fetchIfNeeded]> has been called. No network request will be made. 38 | A default implementation is provided by PFObject which should always be sufficient. 39 | 40 | @param objectId The object id for the referenced object. 41 | 42 | @returns A new without data. 43 | */ 44 | + (instancetype)objectWithoutDataWithObjectId:(NSString *)objectId; 45 | 46 | /*! 47 | @abstract The name of the class as seen in the REST API. 48 | */ 49 | + (NSString *)parseClassName; 50 | 51 | /*! 52 | @abstract Create a query which returns objects of this type. 53 | 54 | @discussion A default implementation is provided by which should always be sufficient. 55 | */ 56 | + (PFQuery *)query; 57 | 58 | /*! 59 | @abstract Returns a query for objects of this type with a given predicate. 60 | 61 | @discussion A default implementation is provided by which should always be sufficient. 62 | 63 | @param predicate The predicate to create conditions from. 64 | 65 | @returns An instance of . 66 | 67 | @see [PFQuery queryWithClassName:predicate:] 68 | */ 69 | + (PFQuery *)queryWithPredicate:(NSPredicate *)predicate; 70 | 71 | /*! 72 | @abstract Lets Parse know this class should be used to instantiate all objects with class type . 73 | 74 | @warning This method must be called before <[Parse setApplicationId:clientKey:]> 75 | */ 76 | + (void)registerSubclass; 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Parse.framework/Headers/PF_Twitter.h: -------------------------------------------------------------------------------- 1 | // 2 | // PF_Twitter.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #import 10 | 11 | PF_ASSUME_NONNULL_BEGIN 12 | 13 | @class BFTask; 14 | 15 | /*! 16 | The `PF_Twitter` class is a simple interface for interacting with the Twitter REST API, 17 | automating sign-in and OAuth signing of requests against the API. 18 | */ 19 | @interface PF_Twitter : NSObject 20 | 21 | /*! 22 | @abstract Consumer key of the application that is used to authorize with Twitter. 23 | */ 24 | @property (PF_NULLABLE_PROPERTY nonatomic, copy) NSString *consumerKey; 25 | 26 | /*! 27 | @abstract Consumer secret of the application that is used to authorize with Twitter. 28 | */ 29 | @property (PF_NULLABLE_PROPERTY nonatomic, copy) NSString *consumerSecret; 30 | 31 | /*! 32 | @abstract Auth token for the current user. 33 | */ 34 | @property (PF_NULLABLE_PROPERTY nonatomic, copy) NSString *authToken; 35 | 36 | /*! 37 | @abstract Auth token secret for the current user. 38 | */ 39 | @property (PF_NULLABLE_PROPERTY nonatomic, copy) NSString *authTokenSecret; 40 | 41 | /*! 42 | @abstract Twitter user id of the currently signed in user. 43 | */ 44 | @property (PF_NULLABLE_PROPERTY nonatomic, copy) NSString *userId; 45 | 46 | /*! 47 | @abstract Twitter screen name of the currently signed in user. 48 | */ 49 | @property (PF_NULLABLE_PROPERTY nonatomic, copy) NSString *screenName; 50 | 51 | /*! 52 | @abstract Displays an auth dialog and populates the authToken, authTokenSecret, userId, and screenName properties 53 | if the Twitter user grants permission to the application. 54 | 55 | @returns The task, that encapsulates the work being done. 56 | */ 57 | - (BFTask *)authorizeInBackground; 58 | 59 | /*! 60 | @abstract Displays an auth dialog and populates the authToken, authTokenSecret, userId, and screenName properties 61 | if the Twitter user grants permission to the application. 62 | 63 | @param success Invoked upon successful authorization. 64 | @param failure Invoked upon an error occurring in the authorization process. 65 | @param cancel Invoked when the user cancels authorization. 66 | */ 67 | - (void)authorizeWithSuccess:(PF_NULLABLE void (^)(void))success 68 | failure:(PF_NULLABLE void (^)(PF_NULLABLE_S NSError *error))failure 69 | cancel:(PF_NULLABLE void (^)(void))cancel; 70 | 71 | /*! 72 | @abstract Adds a 3-legged OAuth signature to an `NSMutableURLRequest` based 73 | upon the properties set for the Twitter object. 74 | 75 | @discussion Use this function to sign requests being made to the Twitter API. 76 | 77 | @param request Request to sign. 78 | */ 79 | - (void)signRequest:(PF_NULLABLE NSMutableURLRequest *)request; 80 | 81 | @end 82 | 83 | PF_ASSUME_NONNULL_END 84 | -------------------------------------------------------------------------------- /Parse.framework/Headers/Parse.h: -------------------------------------------------------------------------------- 1 | // 2 | // Parse.h 3 | // 4 | // Copyright 2011-present Parse Inc. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | #if TARGET_OS_IPHONE 10 | 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | #import 31 | #import 32 | 33 | #else 34 | 35 | #import 36 | #import 37 | #import 38 | #import 39 | #import 40 | #import 41 | #import 42 | #import 43 | #import 44 | #import 45 | #import 46 | #import 47 | #import 48 | #import 49 | #import 50 | 51 | #endif 52 | 53 | PF_ASSUME_NONNULL_BEGIN 54 | 55 | /*! 56 | The `Parse` class contains static functions that handle global configuration for the Parse framework. 57 | */ 58 | @interface Parse : NSObject 59 | 60 | ///-------------------------------------- 61 | /// @name Connecting to Parse 62 | ///-------------------------------------- 63 | 64 | /*! 65 | @abstract Sets the applicationId and clientKey of your application. 66 | 67 | @param applicationId The application id of your Parse application. 68 | @param clientKey The client key of your Parse application. 69 | */ 70 | + (void)setApplicationId:(NSString *)applicationId clientKey:(NSString *)clientKey; 71 | 72 | /*! 73 | @abstract The current application id that was used to configure Parse framework. 74 | */ 75 | + (NSString *)getApplicationId; 76 | 77 | /*! 78 | @abstract The current client key that was used to configure Parse framework. 79 | */ 80 | + (NSString *)getClientKey; 81 | 82 | ///-------------------------------------- 83 | /// @name Enabling Local Datastore 84 | ///-------------------------------------- 85 | 86 | /*! 87 | @abstract Enable pinning in your application. This must be called before your application can use 88 | pinning. The recommended way is to call this method before `setApplicationId:clientKey:`. 89 | */ 90 | + (void)enableLocalDatastore; 91 | 92 | /*! 93 | @abstract Flag that indicates whether Local Datastore is enabled. 94 | 95 | @returns `YES` if Local Datastore is enabled, otherwise `NO`. 96 | */ 97 | + (BOOL)isLocalDatastoreEnabled; 98 | 99 | #if PARSE_IOS_ONLY 100 | 101 | ///-------------------------------------- 102 | /// @name Configuring UI Settings 103 | ///-------------------------------------- 104 | 105 | /*! 106 | @abstract Set whether to show offline messages when using a Parse view or view controller related classes. 107 | 108 | @param enabled Whether a `UIAlertView` should be shown when the device is offline 109 | and network access is required from a view or view controller. 110 | */ 111 | + (void)offlineMessagesEnabled:(BOOL)enabled; 112 | 113 | /*! 114 | @abstract Set whether to show an error message when using a Parse view or view controller related classes 115 | and a Parse error was generated via a query. 116 | 117 | @param enabled Whether a `UIAlertView` should be shown when an error occurs. 118 | */ 119 | + (void)errorMessagesEnabled:(BOOL)enabled; 120 | 121 | #endif 122 | 123 | ///-------------------------------------- 124 | /// @name Logging 125 | ///-------------------------------------- 126 | 127 | /*! 128 | @abstract Sets the level of logging to display. 129 | 130 | @discussion By default: 131 | - If running inside an app that was downloaded from iOS App Store - it is set to 132 | - All other cases - it is set to 133 | 134 | @param logLevel Log level to set. 135 | @see PFLogLevel 136 | */ 137 | + (void)setLogLevel:(PFLogLevel)logLevel; 138 | 139 | /*! 140 | @abstract Log level that will be displayed. 141 | 142 | @discussion By default: 143 | - If running inside an app that was downloaded from iOS App Store - it is set to 144 | - All other cases - it is set to 145 | 146 | @returns A value. 147 | @see PFLogLevel 148 | */ 149 | + (PFLogLevel)logLevel; 150 | 151 | @end 152 | 153 | PF_ASSUME_NONNULL_END 154 | -------------------------------------------------------------------------------- /Parse.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyuanme/ble-swift/7d706c6d4219e250c10c05db0a36bbea0cb24bc3/Parse.framework/Info.plist -------------------------------------------------------------------------------- /Parse.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module Parse { 2 | umbrella header "Parse.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Parse.framework/Parse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyuanme/ble-swift/7d706c6d4219e250c10c05db0a36bbea0cb24bc3/Parse.framework/Parse -------------------------------------------------------------------------------- /Parse.framework/Resources/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyuanme/ble-swift/7d706c6d4219e250c10c05db0a36bbea0cb24bc3/Parse.framework/Resources/Localizable.strings -------------------------------------------------------------------------------- /Parse.framework/third_party_licenses.txt: -------------------------------------------------------------------------------- 1 | THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THE PARSE PRODUCT. 2 | 3 | ----- 4 | 5 | The following software may be included in this product: AFNetworking. This software contains the following license and notice below: 6 | 7 | Copyright (c) 2011 Gowalla (http://gowalla.com/) 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | 27 | ----- 28 | 29 | The following software may be included in this product: OAuthCore. This software contains the following license and notice below: 30 | 31 | Copyright (C) 2012 Loren Brichter 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 34 | 35 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38 | 39 | ----- 40 | 41 | The following software may be included in this product: google-breakpad. This software contains the following license and notice below: 42 | 43 | Copyright (c) 2006, Google Inc. 44 | All rights reserved. 45 | 46 | Redistribution and use in source and binary forms, with or without 47 | modification, are permitted provided that the following conditions are 48 | met: 49 | 50 | * Redistributions of source code must retain the above copyright 51 | notice, this list of conditions and the following disclaimer. 52 | * Redistributions in binary form must reproduce the above 53 | copyright notice, this list of conditions and the following disclaimer 54 | in the documentation and/or other materials provided with the 55 | distribution. 56 | * Neither the name of Google Inc. nor the names of its 57 | contributors may be used to endorse or promote products derived from 58 | this software without specific prior written permission. 59 | 60 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 61 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 62 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 63 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 64 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 65 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 66 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 67 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 68 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 69 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 70 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 71 | 72 | -------------------------------------------------------------------- 73 | 74 | Copyright 2001-2004 Unicode, Inc. 75 | 76 | Disclaimer 77 | 78 | This source code is provided as is by Unicode, Inc. No claims are 79 | made as to fitness for any particular purpose. No warranties of any 80 | kind are expressed or implied. The recipient agrees to determine 81 | applicability of information provided. If this file has been 82 | purchased on magnetic or optical media from Unicode, Inc., the 83 | sole remedy for any claim will be exchange of defective media 84 | within 90 days of receipt. 85 | 86 | Limitations on Rights to Redistribute This Code 87 | 88 | Unicode, Inc. hereby grants the right to freely use the information 89 | supplied in this file in the creation of products supporting the 90 | Unicode Standard, and to make copies of this file in any form 91 | for internal or external distribution as long as this notice 92 | remains attached. 93 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | 26 | PFUI_ASSUME_NONNULL_BEGIN 27 | 28 | @class PFImageView; 29 | @class PFObject; 30 | 31 | /*! 32 | The `PFCollectionViewCell` class represents a collection view cell which can 33 | download and display remote images stored on Parse as well as has a default simple text label. 34 | */ 35 | @interface PFCollectionViewCell : UICollectionViewCell 36 | 37 | /*! 38 | @abstract A simple lazy-loaded label for the collection view cell. 39 | */ 40 | @property (nonatomic, strong, readonly) UILabel *textLabel; 41 | 42 | /*! 43 | @abstract The lazy-loaded imageView of the collection view cell. 44 | 45 | @see PFImageView 46 | */ 47 | @property (nonatomic, strong, readonly) PFImageView *imageView; 48 | 49 | /*! 50 | @abstract This method should update all the relevant information inside a subclass of `PFCollectionViewCell`. 51 | 52 | @discussion This method is automatically called by whenever the cell 53 | should display new information. By default this method does nothing. 54 | 55 | @param object An instance of `PFObject` to update from. 56 | */ 57 | - (void)updateFromObject:(PFUI_NULLABLE PFObject *)object; 58 | 59 | @end 60 | 61 | PFUI_ASSUME_NONNULL_END 62 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFImageView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | 26 | PFUI_ASSUME_NONNULL_BEGIN 27 | 28 | @class BFTask; 29 | @class PFFile; 30 | 31 | /*! 32 | An image view that downloads and displays remote image stored on Parse's server. 33 | */ 34 | @interface PFImageView : UIImageView 35 | 36 | /*! 37 | @abstract The remote file on Parse's server that stores the image. 38 | 39 | @warning Note that the download does not start until is called. 40 | */ 41 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong) PFFile *file; 42 | 43 | /*! 44 | @abstract Initiate downloading of the remote image. 45 | 46 | @discussion Once the download completes, the remote image will be displayed. 47 | 48 | @returns The task, that encapsulates the work being done. 49 | */ 50 | - (BFTask *)loadInBackground; 51 | 52 | /*! 53 | @abstract Initiate downloading of the remote image. 54 | 55 | @discussion Once the download completes, the remote image will be displayed. 56 | 57 | @param completion the completion block. 58 | */ 59 | - (void)loadInBackground:(PFUI_NULLABLE void (^)(PFUI_NULLABLE_S UIImage *image, PFUI_NULLABLE_S NSError *error))completion; 60 | 61 | /*! 62 | @abstract Initiate downloading of the remote image. 63 | 64 | @discussion Once the download completes, the remote image will be displayed. 65 | 66 | @param completion the completion block. 67 | @param progressBlock called with the download progress as the image is being downloaded. 68 | Will be called with a value of 100 before the completion block is called. 69 | */ 70 | - (void)loadInBackground:(PFUI_NULLABLE void (^)(PFUI_NULLABLE_S UIImage *image, PFUI_NULLABLE_S NSError *error))completion 71 | progressBlock:(PFUI_NULLABLE void (^)(int percentDone))progressBlock; 72 | 73 | @end 74 | 75 | PFUI_ASSUME_NONNULL_END 76 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFLogInView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | 26 | PFUI_ASSUME_NONNULL_BEGIN 27 | 28 | /*! 29 | `PFLogInFields` bitmask specifies the log in elements which are enabled in the view. 30 | 31 | @see PFLogInViewController 32 | @see PFLogInView 33 | */ 34 | typedef NS_OPTIONS(NSInteger, PFLogInFields) { 35 | /*! No fields. */ 36 | PFLogInFieldsNone = 0, 37 | /*! Username and password fields. */ 38 | PFLogInFieldsUsernameAndPassword = 1 << 0, 39 | /*! Forgot password button. */ 40 | PFLogInFieldsPasswordForgotten = 1 << 1, 41 | /*! Login button. */ 42 | PFLogInFieldsLogInButton = 1 << 2, 43 | /*! Button to login with Facebook. */ 44 | PFLogInFieldsFacebook = 1 << 3, 45 | /*! Button to login with Twitter. */ 46 | PFLogInFieldsTwitter = 1 << 4, 47 | /*! Signup Button. */ 48 | PFLogInFieldsSignUpButton = 1 << 5, 49 | /*! Dismiss Button. */ 50 | PFLogInFieldsDismissButton = 1 << 6, 51 | 52 | /*! Default value. Combines Username, Password, Login, Signup, Forgot Password and Dismiss buttons. */ 53 | PFLogInFieldsDefault = (PFLogInFieldsUsernameAndPassword | 54 | PFLogInFieldsLogInButton | 55 | PFLogInFieldsSignUpButton | 56 | PFLogInFieldsPasswordForgotten | 57 | PFLogInFieldsDismissButton) 58 | }; 59 | 60 | @class PFTextField; 61 | 62 | /*! 63 | The `PFLogInView` class provides a standard log in interface for authenticating a . 64 | */ 65 | @interface PFLogInView : UIScrollView 66 | 67 | ///-------------------------------------- 68 | /// @name Creating Log In View 69 | ///-------------------------------------- 70 | 71 | /*! 72 | @abstract Initializes the view with the specified log in elements. 73 | 74 | @param fields A bitmask specifying the log in elements which are enabled in the view 75 | 76 | @returns An initialized `PFLogInView` object or `nil` if the object couldn't be created. 77 | 78 | @see PFLogInFields 79 | */ 80 | - (instancetype)initWithFields:(PFLogInFields)fields; 81 | 82 | /*! 83 | @abstract The view controller that will present this view. 84 | 85 | @discussion Used to lay out elements correctly when the presenting view controller has translucent elements. 86 | */ 87 | @property (PFUI_NULLABLE_PROPERTY nonatomic, weak) UIViewController *presentingViewController; 88 | 89 | ///-------------------------------------- 90 | /// @name Customizing the Logo 91 | ///-------------------------------------- 92 | 93 | /// The logo. By default, it is the Parse logo. 94 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong) UIView *logo; 95 | 96 | ///-------------------------------------- 97 | /// @name Configure Username Behaviour 98 | ///-------------------------------------- 99 | 100 | /*! 101 | @abstract If email should be used to log in, instead of username 102 | 103 | @discussion By default, this is set to `NO`. 104 | */ 105 | @property (nonatomic, assign) BOOL emailAsUsername; 106 | 107 | ///-------------------------------------- 108 | /// @name Log In Elements 109 | ///-------------------------------------- 110 | 111 | /*! 112 | @abstract The bitmask which specifies the enabled log in elements in the view. 113 | */ 114 | @property (nonatomic, assign, readonly) PFLogInFields fields; 115 | 116 | /*! 117 | @abstract The username text field. It is `nil` if the element is not enabled. 118 | */ 119 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) PFTextField *usernameField; 120 | 121 | /*! 122 | @abstract The password text field. It is `nil` if the element is not enabled. 123 | */ 124 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) PFTextField *passwordField; 125 | 126 | /*! 127 | @abstract The password forgotten button. It is `nil` if the element is not enabled. 128 | */ 129 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UIButton *passwordForgottenButton; 130 | 131 | /*! 132 | @abstract The log in button. It is `nil` if the element is not enabled. 133 | */ 134 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UIButton *logInButton; 135 | 136 | /*! 137 | @abstract The Facebook button. It is `nil` if the element is not enabled. 138 | */ 139 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UIButton *facebookButton; 140 | 141 | /*! 142 | @abstract The Twitter button. It is `nil` if the element is not enabled. 143 | */ 144 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UIButton *twitterButton; 145 | 146 | /*! 147 | @abstract The sign up button. It is `nil` if the element is not enabled. 148 | */ 149 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UIButton *signUpButton; 150 | 151 | /*! 152 | @abstract It is `nil` if the element is not enabled. 153 | */ 154 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UIButton *dismissButton; 155 | 156 | /*! 157 | @abstract The facebook/twitter login label. 158 | 159 | @deprecated This property is deprecated and will always be nil. 160 | */ 161 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UILabel *externalLogInLabel __attribute__(PARSE_UI_DEPRECATED("This property is deprecated and will always be nil.")); 162 | 163 | /*! 164 | @abstract The sign up label. 165 | 166 | @deprecated This property is deprecated and will always be nil. 167 | */ 168 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UILabel *signUpLabel __attribute__(PARSE_UI_DEPRECATED("This property is deprecated and will always be nil.")); 169 | 170 | @end 171 | 172 | PFUI_ASSUME_NONNULL_END 173 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFLogInViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | #import 26 | 27 | PFUI_ASSUME_NONNULL_BEGIN 28 | 29 | @class PFSignUpViewController; 30 | @class PFUser; 31 | @protocol PFLogInViewControllerDelegate; 32 | 33 | /*! 34 | The `PFLogInViewController` class presents and manages a standard authentication interface for logging in a . 35 | */ 36 | @interface PFLogInViewController : UIViewController 37 | 38 | ///-------------------------------------- 39 | /// @name Configuring Log In Elements 40 | ///-------------------------------------- 41 | 42 | /*! 43 | @abstract A bitmask specifying the log in elements which are enabled in the view. 44 | 45 | @see PFLogInFields 46 | */ 47 | @property (nonatomic, assign) PFLogInFields fields; 48 | 49 | 50 | /*! 51 | @abstract The log in view. It contains all the enabled log in elements. 52 | 53 | @see PFLogInView 54 | */ 55 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) PFLogInView *logInView; 56 | 57 | ///-------------------------------------- 58 | /// @name Configuring Log In Behaviors 59 | ///-------------------------------------- 60 | 61 | /*! 62 | @abstract The delegate that responds to the control events of `PFLogInViewController`. 63 | 64 | @see PFLogInViewControllerDelegate 65 | */ 66 | @property (PFUI_NULLABLE_PROPERTY nonatomic, weak) id delegate; 67 | 68 | /*! 69 | @abstract The facebook permissions that Facebook log in requests for. 70 | 71 | @discussion If unspecified, the default is basic facebook permissions. 72 | */ 73 | @property (PFUI_NULLABLE_PROPERTY nonatomic, copy) NSArray *facebookPermissions; 74 | 75 | /*! 76 | @abstract The sign up controller if sign up is enabled. 77 | 78 | @discussion Use this to configure the sign up view, and the transition animation to the sign up view. 79 | The default is a sign up view with a username, a password, a dismiss button and a sign up button. 80 | */ 81 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong) PFSignUpViewController *signUpController; 82 | 83 | /*! 84 | @abstract Whether to prompt for the email as username on the login view. 85 | 86 | @discussion If set to `YES`, we'll prompt for the email in the username field. 87 | This property value propagates to the attached . 88 | By default, this is set to `NO`. 89 | */ 90 | @property (nonatomic, assign) BOOL emailAsUsername; 91 | 92 | @end 93 | 94 | ///-------------------------------------- 95 | /// @name Notifications 96 | ///-------------------------------------- 97 | 98 | /*! 99 | @abstract The notification is posted immediately after the log in succeeds. 100 | */ 101 | extern NSString *const PFLogInSuccessNotification; 102 | 103 | /*! 104 | @abstract The notification is posted immediately after the log in fails. 105 | @discussion If the delegate prevents the log in from starting, the notification is not sent. 106 | */ 107 | extern NSString *const PFLogInFailureNotification; 108 | 109 | /*! 110 | @abstract The notification is posted immediately after the log in is cancelled. 111 | */ 112 | extern NSString *const PFLogInCancelNotification; 113 | 114 | ///-------------------------------------- 115 | /// @name PFLogInViewControllerDelegate 116 | ///-------------------------------------- 117 | 118 | /*! 119 | The `PFLogInViewControllerDelegate` protocol defines methods a delegate of a should implement. 120 | All methods of this protocol are optional. 121 | */ 122 | @protocol PFLogInViewControllerDelegate 123 | 124 | @optional 125 | 126 | ///-------------------------------------- 127 | /// @name Customizing Behavior 128 | ///-------------------------------------- 129 | 130 | /*! 131 | @abstract Sent to the delegate to determine whether the log in request should be submitted to the server. 132 | 133 | @param logInController The login view controller that is requesting the data. 134 | @param username the username the user tries to log in with. 135 | @param password the password the user tries to log in with. 136 | 137 | @returns A `BOOL` indicating whether the log in should proceed. 138 | */ 139 | - (BOOL)logInViewController:(PFLogInViewController *)logInController 140 | shouldBeginLogInWithUsername:(NSString *)username 141 | password:(NSString *)password; 142 | 143 | ///-------------------------------------- 144 | /// @name Responding to Actions 145 | ///-------------------------------------- 146 | 147 | /*! 148 | @abstract Sent to the delegate when a is logged in. 149 | 150 | @param logInController The login view controller where login finished. 151 | @param user object that is a result of the login. 152 | */ 153 | - (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user; 154 | 155 | /*! 156 | @abstract Sent to the delegate when the log in attempt fails. 157 | 158 | @param logInController The login view controller where login failed. 159 | @param error `NSError` object representing the error that occured. 160 | */ 161 | - (void)logInViewController:(PFLogInViewController *)logInController 162 | didFailToLogInWithError:(PFUI_NULLABLE NSError *)error; 163 | 164 | /*! 165 | @abstract Sent to the delegate when the log in screen is cancelled. 166 | 167 | @param logInController The login view controller where login was cancelled. 168 | */ 169 | - (void)logInViewControllerDidCancelLogIn:(PFLogInViewController *)logInController; 170 | 171 | @end 172 | 173 | PFUI_ASSUME_NONNULL_END 174 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFProductTableViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | #import 26 | 27 | PFUI_ASSUME_NONNULL_BEGIN 28 | 29 | /*! 30 | `PFProductTableViewController` displays in-app purchase products stored on Parse. 31 | In addition to setting up in-app purchases in iTunes Connect, the app developer needs 32 | to register product information on Parse, in the Product class. 33 | */ 34 | @interface PFProductTableViewController : PFQueryTableViewController 35 | 36 | /*! 37 | @abstract Initializes a product table view controller. 38 | 39 | @param style The UITableViewStyle for the table 40 | 41 | @returns An initialized `PFProductTableViewController` object or `nil` if the object couldn't be created. 42 | */ 43 | - (instancetype)initWithStyle:(UITableViewStyle)style NS_DESIGNATED_INITIALIZER; 44 | 45 | @end 46 | 47 | PFUI_ASSUME_NONNULL_END 48 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFPurchaseTableViewCell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | #import 26 | 27 | PFUI_ASSUME_NONNULL_BEGIN 28 | 29 | /*! 30 | An enum that represents states of the PFPurchaseTableViewCell. 31 | @see PFPurchaseTableViewCell 32 | */ 33 | typedef NS_ENUM(uint8_t, PFPurchaseTableViewCellState) { 34 | /*! Normal state of the cell. */ 35 | PFPurchaseTableViewCellStateNormal = 0, 36 | /*! Downloading state of the cell. */ 37 | PFPurchaseTableViewCellStateDownloading, 38 | /*! State of the cell, when the product was downloaded. */ 39 | PFPurchaseTableViewCellStateDownloaded 40 | }; 41 | 42 | /*! 43 | `PFPurchaseTableViewCell` is a subclass that is used to show 44 | products in a . 45 | 46 | @see PFProductTableViewController 47 | */ 48 | @interface PFPurchaseTableViewCell : PFTableViewCell 49 | 50 | /*! 51 | @abstract State of the cell. 52 | @see PFPurchaseTableViewCellState 53 | */ 54 | @property (nonatomic, assign) PFPurchaseTableViewCellState state; 55 | 56 | /*! 57 | @abstract Label where price of the product is displayed. 58 | */ 59 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UILabel *priceLabel; 60 | 61 | /*! 62 | @abstract Progress view that is shown, when the product is downloading. 63 | */ 64 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UIProgressView *progressView; 65 | 66 | @end 67 | 68 | PFUI_ASSUME_NONNULL_END 69 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFQueryCollectionViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | 26 | PFUI_ASSUME_NONNULL_BEGIN 27 | 28 | @class PFCollectionViewCell; 29 | @class PFObject; 30 | @class PFQuery; 31 | 32 | /*! 33 | This class allows you to think about a one-to-one mapping between a and a `UICollectionViewCell`, 34 | rather than having to juggle index paths. 35 | 36 | You also get the following features out of the box: 37 | 38 | - Pagination with a cell that can be tapped to load the next page. 39 | - Pull-to-refresh collection view header. 40 | - Automatic downloading and displaying of remote images in cells. 41 | - Loading screen, shown before any data is loaded. 42 | - Automatic loading and management of the objects array. 43 | - Various methods that can be overridden to customize behavior at major events in the data cycle. 44 | 45 | @see PFCollectionViewCell 46 | */ 47 | @interface PFQueryCollectionViewController : UICollectionViewController 48 | 49 | /*! 50 | @abstract The class name of the this collection will use as a datasource. 51 | */ 52 | @property (PFUI_NULLABLE_PROPERTY nonatomic, copy) IBInspectable NSString *parseClassName; 53 | 54 | /*! 55 | @abstract Whether the collection should use the default loading view. Default - `YES`. 56 | */ 57 | @property (nonatomic, assign) IBInspectable BOOL loadingViewEnabled; 58 | 59 | /*! 60 | @abstract Whether the collection should use the built-in pull-to-refresh feature. Defualt - `YES`. 61 | */ 62 | @property (nonatomic, assign) IBInspectable BOOL pullToRefreshEnabled; 63 | 64 | /*! 65 | @abstract Whether the collection should use the built-in pagination feature. Default - `YES`. 66 | */ 67 | @property (nonatomic, assign) IBInspectable BOOL paginationEnabled; 68 | 69 | /*! 70 | @abstract The number of objects to show per page. Default - `25`. 71 | */ 72 | @property (nonatomic, assign) IBInspectable NSUInteger objectsPerPage; 73 | 74 | /*! 75 | @abstract Whether the collection is actively loading new data from the server. 76 | */ 77 | @property (nonatomic, assign, getter=isLoading) BOOL loading; 78 | 79 | ///-------------------------------------- 80 | /// @name Creating a PFQueryCollectionViewController 81 | ///-------------------------------------- 82 | 83 | /*! 84 | @abstract Initializes a view controller with a `UICollectionViewFlowLayout` and a class name 85 | of that will be associated with this collection. 86 | 87 | @param className The class name of the instances of that this table will display. 88 | 89 | @returns An initialized `PFQueryCollectionViewController` object or `nil` if the object couldn't be created. 90 | */ 91 | - (instancetype)initWithClassName:(PFUI_NULLABLE NSString *)className; 92 | 93 | /*! 94 | @abstract Initializes a view controller with a class name of that will be associated with this collection. 95 | 96 | @param layout Layout for collection view to use. 97 | @param className The class name of the instances of that this table will display. 98 | 99 | @returns An initialized `PFQueryCollectionViewController` object or `nil` if the object couldn't be created. 100 | */ 101 | - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout 102 | className:(PFUI_NULLABLE NSString *)className NS_DESIGNATED_INITIALIZER; 103 | 104 | ///-------------------------------------- 105 | /// @name Responding to Events 106 | ///-------------------------------------- 107 | 108 | /*! 109 | Called when objects will be loaded from Parse. If you override this method, you must 110 | call [super objectsWillLoad] in your implementation. 111 | */ 112 | - (void)objectsWillLoad NS_REQUIRES_SUPER; 113 | 114 | /*! 115 | Called when objects have loaded from Parse. If you override this method, you must 116 | call [super objectsDidLoad:] in your implementation. 117 | @param error The Parse error from running the PFQuery, if there was any. 118 | */ 119 | - (void)objectsDidLoad:(PFUI_NULLABLE NSError *)error NS_REQUIRES_SUPER; 120 | 121 | ///-------------------------------------- 122 | /// @name Accessing Results 123 | ///-------------------------------------- 124 | 125 | /*! 126 | @abstract The array of instances of that is used as a data source. 127 | */ 128 | @property (nonatomic, copy, readonly) NSArray *objects; 129 | 130 | /*! 131 | @abstract Returns an object at a particular indexPath. 132 | 133 | @discussion The default impementation returns the object at `indexPath.item`. 134 | If you want to return objects in a different indexPath order, like for sections, override this method. 135 | 136 | @param indexPath An instance of `NSIndexPath`. 137 | 138 | @returns The object at the specified indexPath. 139 | */ 140 | - (PFUI_NULLABLE PFObject *)objectAtIndexPath:(PFUI_NULLABLE NSIndexPath *)indexPath; 141 | 142 | ///-------------------------------------- 143 | /// @name Loading Data 144 | ///-------------------------------------- 145 | 146 | /*! 147 | @abstract Clears the collection view and loads the first page of objects. 148 | */ 149 | - (void)loadObjects; 150 | 151 | /*! 152 | @abstract Loads the objects of the at the specified page and appends it to the 153 | objects already loaded and refreshes the collection. 154 | 155 | @param page The page of objects to load. 156 | @param clear Whether to clear the collection view after receiving the objects. 157 | */ 158 | - (void)loadObjects:(NSInteger)page clear:(BOOL)clear; 159 | 160 | /*! 161 | @abstract Loads the next page of objects, appends to table, and refreshes. 162 | */ 163 | - (void)loadNextPage; 164 | 165 | /*! 166 | @abstract Clears the collection view of all objects. 167 | */ 168 | - (void)clear; 169 | 170 | ///-------------------------------------- 171 | /// @name Querying 172 | ///-------------------------------------- 173 | 174 | /*! 175 | @abstract Override to construct your own custom to get the objects. 176 | 177 | @returns An instance of that method will use to the objects for this collection. 178 | */ 179 | - (PFQuery *)queryForCollection; 180 | 181 | ///-------------------------------------- 182 | /// @name Data Source Methods 183 | ///-------------------------------------- 184 | 185 | /*! 186 | @abstract Override this method to customize each cell given a that is loaded. 187 | 188 | @warning The cell should inherit from which is a subclass of `UICollectionViewCell`. 189 | 190 | @param collectionView The collection view object associated with this controller. 191 | @param indexPath The indexPath of the cell. 192 | @param object The that is associated with the cell. 193 | 194 | @returns The cell that represents this object. 195 | */ 196 | - (PFUI_NULLABLE PFCollectionViewCell *)collectionView:(UICollectionView *)collectionView 197 | cellForItemAtIndexPath:(NSIndexPath *)indexPath 198 | object:(PFUI_NULLABLE PFObject *)object; 199 | 200 | /*! 201 | @discussion Override this method to customize the view that allows the user to load the 202 | next page when pagination is turned on. 203 | 204 | @param collectionView The collection view object associated with this controller. 205 | 206 | @returns The view that allows the user to paginate. 207 | */ 208 | - (PFUI_NULLABLE UICollectionReusableView *)collectionViewReusableViewForNextPageAction:(UICollectionView *)collectionView; 209 | 210 | @end 211 | 212 | PFUI_ASSUME_NONNULL_END 213 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFQueryTableViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | 26 | PFUI_ASSUME_NONNULL_BEGIN 27 | 28 | @class PFObject; 29 | @class PFQuery; 30 | @class PFTableViewCell; 31 | 32 | /*! 33 | This class allows you to think about a one-to-one mapping between a and a `UITableViewCell`, 34 | rather than having to juggle index paths. 35 | 36 | You also get the following features out of the box: 37 | 38 | - Pagination with a cell that can be tapped to load the next page. 39 | - Pull-to-refresh table view header. 40 | - Automatic downloading and displaying of remote images in cells. 41 | - Loading screen, shown before any data is loaded. 42 | - Automatic loading and management of the objects array. 43 | - Various methods that can be overridden to customize behavior at major events in the data cycle. 44 | */ 45 | @interface PFQueryTableViewController : UITableViewController 46 | 47 | ///-------------------------------------- 48 | /// @name Creating a PFQueryTableViewController 49 | ///-------------------------------------- 50 | 51 | /*! 52 | @abstract Initializes with a class name of the that will be associated with this table. 53 | 54 | @param style The UITableViewStyle for the table 55 | @param className The class name of the instances of that this table will display. 56 | 57 | @returns An initialized `PFQueryTableViewController` object or `nil` if the object couldn't be created. 58 | */ 59 | - (instancetype)initWithStyle:(UITableViewStyle)style 60 | className:(PFUI_NULLABLE NSString *)className NS_DESIGNATED_INITIALIZER; 61 | 62 | /*! 63 | @abstract Initializes with a class name of the PFObjects that will be associated with this table. 64 | 65 | @param className The class name of the instances of that this table will display. 66 | 67 | @returns An initialized `PFQueryTableViewController` object or `nil` if the object couldn't be created. 68 | */ 69 | - (instancetype)initWithClassName:(PFUI_NULLABLE NSString *)className; 70 | 71 | ///-------------------------------------- 72 | /// @name Configuring Behavior 73 | ///-------------------------------------- 74 | 75 | /*! 76 | @abstract The class name of the this table will use as a datasource. 77 | */ 78 | @property (PFUI_NULLABLE_PROPERTY nonatomic, copy) IBInspectable NSString *parseClassName; 79 | 80 | /*! 81 | @abstract The key to use to display for the cell text label. 82 | 83 | @discussion This won't apply if you override 84 | */ 85 | @property (PFUI_NULLABLE_PROPERTY nonatomic, copy) IBInspectable NSString *textKey; 86 | 87 | /*! 88 | @abstract The key to use to display for the cell image view. 89 | 90 | @discussion This won't apply if you override 91 | */ 92 | @property (PFUI_NULLABLE_PROPERTY nonatomic, copy) IBInspectable NSString *imageKey; 93 | 94 | /*! 95 | @abstract The image to use as a placeholder for the cell images. 96 | 97 | @discussion This won't apply if you override 98 | */ 99 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong) IBInspectable UIImage *placeholderImage; 100 | 101 | /*! 102 | @abstract Whether the table should use the default loading view. Default - `YES`. 103 | */ 104 | @property (nonatomic, assign) IBInspectable BOOL loadingViewEnabled; 105 | 106 | /*! 107 | @abstract Whether the table should use the built-in pull-to-refresh feature. Defualt - `YES`. 108 | */ 109 | @property (nonatomic, assign) IBInspectable BOOL pullToRefreshEnabled; 110 | 111 | /*! 112 | @abstract Whether the table should use the built-in pagination feature. Default - `YES`. 113 | */ 114 | @property (nonatomic, assign) IBInspectable BOOL paginationEnabled; 115 | 116 | /*! 117 | @abstract The number of objects to show per page. Default - `25`. 118 | */ 119 | @property (nonatomic, assign) IBInspectable NSUInteger objectsPerPage; 120 | 121 | /*! 122 | @abstract Whether the table is actively loading new data from the server. 123 | */ 124 | @property (nonatomic, assign, getter=isLoading) BOOL loading; 125 | 126 | ///-------------------------------------- 127 | /// @name Responding to Events 128 | ///-------------------------------------- 129 | 130 | /*! 131 | Called when objects will loaded from Parse. If you override this method, you must 132 | call [super objectsWillLoad] in your implementation. 133 | */ 134 | - (void)objectsWillLoad; 135 | 136 | /*! 137 | Called when objects have loaded from Parse. If you override this method, you must 138 | call [super objectsDidLoad:] in your implementation. 139 | @param error The Parse error from running the PFQuery, if there was any. 140 | */ 141 | - (void)objectsDidLoad:(PFUI_NULLABLE NSError *)error; 142 | 143 | ///-------------------------------------- 144 | /// @name Accessing Results 145 | ///-------------------------------------- 146 | 147 | /*! 148 | @abstract The array of instances of that is used as a data source. 149 | */ 150 | @property (PFUI_NULLABLE_PROPERTY nonatomic, copy, readonly) NSArray *objects; 151 | 152 | /*! 153 | @abstract Returns an object at a particular indexPath. 154 | 155 | @discussion The default impementation returns the object at `indexPath.row`. 156 | If you want to return objects in a different indexPath order, like for sections, override this method. 157 | 158 | @param indexPath The indexPath. 159 | 160 | @returns The object at the specified index 161 | */ 162 | - (PFUI_NULLABLE PFObject *)objectAtIndexPath:(PFUI_NULLABLE NSIndexPath *)indexPath; 163 | 164 | /*! 165 | @abstract Clears the table of all objects. 166 | */ 167 | - (void)clear; 168 | 169 | /*! 170 | @abstract Clears the table and loads the first page of objects. 171 | */ 172 | - (void)loadObjects; 173 | 174 | /*! 175 | @abstract Loads the objects of the className at the specified page and appends it to the 176 | objects already loaded and refreshes the table. 177 | 178 | @param page The page of objects to load. 179 | @param clear Whether to clear the table after receiving the objects. 180 | */ 181 | - (void)loadObjects:(NSInteger)page clear:(BOOL)clear; 182 | 183 | /*! 184 | @abstract Loads the next page of objects, appends to table, and refreshes. 185 | */ 186 | - (void)loadNextPage; 187 | 188 | ///-------------------------------------- 189 | /// @name Querying 190 | ///-------------------------------------- 191 | 192 | /*! 193 | Override to construct your own custom PFQuery to get the objects. 194 | @result PFQuery that loadObjects will use to the objects for this table. 195 | */ 196 | - (PFQuery *)queryForTable; 197 | 198 | ///-------------------------------------- 199 | /// @name Data Source Methods 200 | ///-------------------------------------- 201 | 202 | /*! 203 | @abstract Override this method to customize each cell given a PFObject that is loaded. 204 | 205 | @discussion If you don't override this method, it will use a default style cell and display either 206 | the first data key from the object, or it will display the key as specified with `textKey`, `imageKey`. 207 | 208 | @warning The cell should inherit from which is a subclass of `UITableViewCell`. 209 | 210 | @param tableView The table view object associated with this controller. 211 | @param indexPath The indexPath of the cell. 212 | @param object The PFObject that is associated with the cell. 213 | 214 | @returns The cell that represents this object. 215 | */ 216 | - (PFUI_NULLABLE PFTableViewCell *)tableView:(UITableView *)tableView 217 | cellForRowAtIndexPath:(NSIndexPath *)indexPath 218 | object:(PFUI_NULLABLE PFObject *)object; 219 | 220 | /*! 221 | @discussion Override this method to customize the cell that allows the user to load the 222 | next page when pagination is turned on. 223 | 224 | @param tableView The table view object associated with this controller. 225 | @param indexPath The indexPath of the cell. 226 | 227 | @returns The cell that allows the user to paginate. 228 | */ 229 | - (PFUI_NULLABLE PFTableViewCell *)tableView:(UITableView *)tableView 230 | cellForNextPageAtIndexPath:(NSIndexPath *)indexPath; 231 | 232 | @end 233 | 234 | PFUI_ASSUME_NONNULL_END 235 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFSignUpView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | 26 | PFUI_ASSUME_NONNULL_BEGIN 27 | 28 | /*! 29 | `PFSignUpFields` bitmask specifies the sign up elements which are enabled in the view. 30 | 31 | @see PFSignUpViewController 32 | @see PFSignUpView 33 | */ 34 | typedef NS_OPTIONS(NSInteger, PFSignUpFields) { 35 | /*! Username and password fields. */ 36 | PFSignUpFieldsUsernameAndPassword = 0, 37 | /*! Email field. */ 38 | PFSignUpFieldsEmail = 1 << 0, 39 | /*! This field can be used for something else. */ 40 | PFSignUpFieldsAdditional = 1 << 1, 41 | /*! Sign Up Button */ 42 | PFSignUpFieldsSignUpButton = 1 << 2, 43 | /*! Dismiss Button */ 44 | PFSignUpFieldsDismissButton = 1 << 3, 45 | /*! Default value. Combines Username, Password, Email, Sign Up and Dismiss Buttons. */ 46 | PFSignUpFieldsDefault = (PFSignUpFieldsUsernameAndPassword | 47 | PFSignUpFieldsEmail | 48 | PFSignUpFieldsSignUpButton | 49 | PFSignUpFieldsDismissButton) 50 | }; 51 | 52 | @class PFTextField; 53 | 54 | /*! 55 | The `PFSignUpView` class provides a standard sign up interface for authenticating a . 56 | */ 57 | @interface PFSignUpView : UIScrollView 58 | 59 | ///-------------------------------------- 60 | /// @name Creating SignUp View 61 | ///-------------------------------------- 62 | 63 | /*! 64 | @abstract Initializes the view with the specified sign up elements. 65 | 66 | @param fields A bitmask specifying the sign up elements which are enabled in the view 67 | 68 | @returns An initialized `PFSignUpView` object or `nil` if the object couldn't be created. 69 | 70 | @see PFSignUpFields 71 | */ 72 | - (instancetype)initWithFields:(PFSignUpFields)fields; 73 | 74 | /*! 75 | @abstract The view controller that will present this view. 76 | 77 | @discussion Used to lay out elements correctly when the presenting view controller has translucent elements. 78 | */ 79 | @property (PFUI_NULLABLE_PROPERTY nonatomic, weak) UIViewController *presentingViewController; 80 | 81 | ///-------------------------------------- 82 | /// @name Customizing the Logo 83 | ///-------------------------------------- 84 | 85 | /*! 86 | @abstract The logo. By default, it is the Parse logo. 87 | */ 88 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong) UIView *logo; 89 | 90 | ///-------------------------------------- 91 | /// @name Configure Username Behaviour 92 | ///-------------------------------------- 93 | 94 | /*! 95 | @abstract If email should be used to log in, instead of username 96 | 97 | @discussion By default, this is set to `NO`. 98 | */ 99 | @property (nonatomic, assign) BOOL emailAsUsername; 100 | 101 | ///-------------------------------------- 102 | /// @name Sign Up Elements 103 | ///-------------------------------------- 104 | 105 | /*! 106 | @abstract The bitmask which specifies the enabled sign up elements in the view 107 | */ 108 | @property (nonatomic, assign, readonly) PFSignUpFields fields; 109 | 110 | /*! 111 | @abstract The username text field. 112 | */ 113 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) PFTextField *usernameField; 114 | 115 | /*! 116 | @abstract The password text field. 117 | */ 118 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) PFTextField *passwordField; 119 | 120 | /*! 121 | @abstract The email text field. It is `nil` if the element is not enabled. 122 | */ 123 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) PFTextField *emailField; 124 | 125 | /*! 126 | @abstract The additional text field. It is `nil` if the element is not enabled. 127 | 128 | @discussion This field is intended to be customized. 129 | */ 130 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) PFTextField *additionalField; 131 | 132 | /*! 133 | @abstract The sign up button. It is `nil` if the element is not enabled. 134 | */ 135 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UIButton *signUpButton; 136 | 137 | /*! 138 | @abstract The dismiss button. It is `nil` if the element is not enabled. 139 | */ 140 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) UIButton *dismissButton; 141 | 142 | @end 143 | 144 | PFUI_ASSUME_NONNULL_END 145 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFSignUpViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | #import 26 | 27 | @class PFUser; 28 | @protocol PFSignUpViewControllerDelegate; 29 | 30 | PFUI_ASSUME_NONNULL_BEGIN 31 | 32 | /*! 33 | The `PFSignUpViewController` class that presents and manages 34 | a standard authentication interface for signing up a . 35 | */ 36 | @interface PFSignUpViewController : UIViewController 37 | 38 | ///-------------------------------------- 39 | /// @name Configuring Sign Up Elements 40 | ///-------------------------------------- 41 | 42 | /*! 43 | @abstract A bitmask specifying the log in elements which are enabled in the view. 44 | 45 | @see PFSignUpFields 46 | */ 47 | @property (nonatomic, assign) PFSignUpFields fields; 48 | 49 | /*! 50 | @abstract The sign up view. It contains all the enabled log in elements. 51 | 52 | @see PFSignUpView 53 | */ 54 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) PFSignUpView *signUpView; 55 | 56 | ///-------------------------------------- 57 | /// @name Configuring Sign Up Behaviors 58 | ///-------------------------------------- 59 | 60 | /*! 61 | @abstract The delegate that responds to the control events of `PFSignUpViewController`. 62 | 63 | @see PFSignUpViewControllerDelegate 64 | */ 65 | @property (PFUI_NULLABLE_PROPERTY nonatomic, weak) id delegate; 66 | 67 | /*! 68 | @abstract Minimum required password length for user signups, defaults to `0`. 69 | */ 70 | @property (nonatomic, assign) NSUInteger minPasswordLength; 71 | 72 | /*! 73 | @abstract Whether to use the email as username on the attached . 74 | 75 | @discussion If set to `YES`, we'll hide the email field, prompt for the email in 76 | the username field, and save the email into both username and email 77 | fields on the new object. By default, this is set to `NO`. 78 | */ 79 | @property (nonatomic, assign) BOOL emailAsUsername; 80 | 81 | @end 82 | 83 | ///-------------------------------------- 84 | /// @name Notifications 85 | ///-------------------------------------- 86 | 87 | /*! 88 | @abstract The notification is posted immediately after the sign up succeeds. 89 | */ 90 | extern NSString *const PFSignUpSuccessNotification; 91 | 92 | /*! 93 | @abstract The notification is posted immediately after the sign up fails. 94 | 95 | @discussion If the delegate prevents the sign up to start, the notification is not sent. 96 | */ 97 | extern NSString *const PFSignUpFailureNotification; 98 | 99 | /*! 100 | @abstract The notification is posted immediately after the user cancels sign up. 101 | */ 102 | extern NSString *const PFSignUpCancelNotification; 103 | 104 | ///-------------------------------------- 105 | /// @name PFSignUpViewControllerDelegate 106 | ///-------------------------------------- 107 | 108 | /*! 109 | The `PFLogInViewControllerDelegate` protocol defines methods a delegate of a should implement. 110 | All methods of this protocol are optional. 111 | */ 112 | @protocol PFSignUpViewControllerDelegate 113 | 114 | @optional 115 | 116 | ///-------------------------------------- 117 | /// @name Customizing Behavior 118 | ///-------------------------------------- 119 | 120 | /*! 121 | @abstract Sent to the delegate to determine whether the sign up request should be submitted to the server. 122 | 123 | @param signUpController The signup view controller that is requesting the data. 124 | @param info An `NSDictionary` instance which contains all sign up information that the user entered. 125 | 126 | @returns A `BOOL` indicating whether the sign up should proceed. 127 | */ 128 | - (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info; 129 | 130 | ///-------------------------------------- 131 | /// @name Responding to Actions 132 | ///-------------------------------------- 133 | 134 | /*! 135 | @abstract Sent to the delegate when a is signed up. 136 | 137 | @param signUpController The signup view controller where signup finished. 138 | @param user object that is a result of the sign up. 139 | */ 140 | - (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user; 141 | 142 | /*! 143 | @abstract Sent to the delegate when the sign up attempt fails. 144 | 145 | @param signUpController The signup view controller where signup failed. 146 | @param error `NSError` object representing the error that occured. 147 | */ 148 | - (void)signUpViewController:(PFSignUpViewController *)signUpController 149 | didFailToSignUpWithError:(PFUI_NULLABLE NSError *)error; 150 | 151 | /*! 152 | @abstract Sent to the delegate when the sign up screen is cancelled. 153 | 154 | @param signUpController The signup view controller where signup was cancelled. 155 | */ 156 | - (void)signUpViewControllerDidCancelSignUp:(PFSignUpViewController *)signUpController; 157 | 158 | @end 159 | 160 | PFUI_ASSUME_NONNULL_END 161 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFTableViewCell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | #import 26 | 27 | PFUI_ASSUME_NONNULL_BEGIN 28 | 29 | /*! 30 | The `PFTableViewCell` class represents a table view cell which can download and display remote images stored on Parse. 31 | 32 | When used in a - downloading and displaying of the remote images 33 | are automatically managed by the . 34 | */ 35 | @interface PFTableViewCell : UITableViewCell 36 | 37 | /*! 38 | @abstract The imageView of the table view cell. 39 | 40 | @see PFImageView 41 | */ 42 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong, readonly) PFImageView *imageView; 43 | 44 | @end 45 | 46 | PFUI_ASSUME_NONNULL_END 47 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/PFTextField.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | 24 | #import 25 | 26 | PFUI_ASSUME_NONNULL_BEGIN 27 | 28 | /*! 29 | `PFTextFieldSeparatorStyle` bitmask specifies the style of the separators, 30 | that should be used for a given `PFTextField`. 31 | 32 | @see PFTextField 33 | */ 34 | typedef NS_OPTIONS(uint8_t, PFTextFieldSeparatorStyle){ 35 | /*! No separators are visible. */ 36 | PFTextFieldSeparatorStyleNone = 0, 37 | /*! Separator on top of the text field. */ 38 | PFTextFieldSeparatorStyleTop = 1 << 0, 39 | /*! Separator at the bottom of the text field. */ 40 | PFTextFieldSeparatorStyleBottom = 1 << 1 41 | }; 42 | 43 | /*! 44 | `PFTextField` class serves as a stylable subclass of `UITextField`. 45 | It includes styles that are specific to `ParseUI` framework and allows advanced customization. 46 | */ 47 | @interface PFTextField : UITextField 48 | 49 | /*! 50 | @abstract Separator style bitmask that should be applied to this textfield. 51 | 52 | @discussion Default: 53 | 54 | @see PFTextFieldSeparatorStyle 55 | */ 56 | @property (nonatomic, assign) PFTextFieldSeparatorStyle separatorStyle; 57 | 58 | /*! 59 | @abstract Color that should be used for the separators, if they are visible. 60 | 61 | @discussion Default: `227,227,227,1.0`. 62 | */ 63 | @property (PFUI_NULLABLE_PROPERTY nonatomic, strong) UIColor *separatorColor UI_APPEARANCE_SELECTOR; 64 | 65 | /*! 66 | This method is a convenience initializer that sets both `frame` and `separatorStyle` for an instance of `PFTextField.` 67 | 68 | @param frame The frame rectangle for the view, measured in points. 69 | @param separatorStyle Initial separator style to use. 70 | 71 | @return An initialized instance of `PFTextField` or `nil` if it couldn't be created. 72 | */ 73 | - (instancetype)initWithFrame:(CGRect)frame separatorStyle:(PFTextFieldSeparatorStyle)separatorStyle; 74 | 75 | @end 76 | 77 | PFUI_ASSUME_NONNULL_END 78 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/ParseUI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | #import 31 | #import 32 | #import 33 | #import 34 | #import 35 | -------------------------------------------------------------------------------- /ParseUI.framework/Headers/ParseUIConstants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Parse, LLC. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, 5 | * copy, modify, and distribute this software in source code or binary form for use 6 | * in connection with the web services and APIs provided by Parse. 7 | * 8 | * As with any software that integrates with the Parse platform, your use of 9 | * this software is subject to the Parse Terms of Service 10 | * [https://www.parse.com/about/terms]. This copyright notice shall be 11 | * included in all copies or substantial portions of the software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | */ 21 | 22 | #import 23 | #import 24 | 25 | #ifndef ParseUI_ParseUIConstants_h 26 | #define ParseUI_ParseUIConstants_h 27 | 28 | ///-------------------------------------- 29 | /// @name Deprecated Macros 30 | ///-------------------------------------- 31 | 32 | #ifndef PARSE_UI_DEPRECATED 33 | # ifdef __deprecated_msg 34 | # define PARSE_UI_DEPRECATED(_MSG) (deprecated(_MSG)) 35 | # else 36 | # ifdef __deprecated 37 | # define PARSE_UI_DEPRECATED(_MSG) (deprecated) 38 | # else 39 | # define PARSE_UI_DEPRECATED(_MSG) 40 | # endif 41 | # endif 42 | #endif 43 | 44 | ///-------------------------------------- 45 | /// @name Nullability Support 46 | ///-------------------------------------- 47 | 48 | #if __has_feature(nullability) 49 | # define PFUI_NULLABLE nullable 50 | # define PFUI_NULLABLE_S __nullable 51 | # define PFUI_NULL_UNSPECIFIED null_unspecified 52 | # define PFUI_NULLABLE_PROPERTY nullable, 53 | #else 54 | # define PFUI_NULLABLE 55 | # define PFUI_NULLABLE_S 56 | # define PFUI_NULL_UNSPECIFIED 57 | # define PFUI_NULLABLE_PROPERTY 58 | #endif 59 | 60 | #if __has_feature(assume_nonnull) 61 | # ifdef NS_ASSUME_NONNULL_BEGIN 62 | # define PFUI_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN 63 | # else 64 | # define PFUI_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") 65 | # endif 66 | # ifdef NS_ASSUME_NONNULL_END 67 | # define PFUI_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END 68 | # else 69 | # define PFUI_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") 70 | # endif 71 | #else 72 | # define PFUI_ASSUME_NONNULL_BEGIN 73 | # define PFUI_ASSUME_NONNULL_END 74 | #endif 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /ParseUI.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyuanme/ble-swift/7d706c6d4219e250c10c05db0a36bbea0cb24bc3/ParseUI.framework/Info.plist -------------------------------------------------------------------------------- /ParseUI.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module ParseUI { 2 | umbrella header "ParseUI.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /ParseUI.framework/ParseUI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyuanme/ble-swift/7d706c6d4219e250c10c05db0a36bbea0cb24bc3/ParseUI.framework/ParseUI -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ble-swift 2 | ========= 3 | -------------------------------------------------------------------------------- /ble-swift.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ble-swift/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ble-swift/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ble-swift/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "minimum-system-version" : "7.0", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "orientation" : "portrait", 11 | "idiom" : "iphone", 12 | "minimum-system-version" : "7.0", 13 | "subtype" : "retina4", 14 | "scale" : "2x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ble-swift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.hoperun.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSLocationAlwaysUsageDescription 26 | This will help the app to better work 27 | UIBackgroundModes 28 | 29 | bluetooth-central 30 | bluetooth-peripheral 31 | remote-notification 32 | 33 | UILaunchStoryboardName 34 | LaunchScreen 35 | UIMainStoryboardFile 36 | Main 37 | UIRequiredDeviceCapabilities 38 | 39 | armv7 40 | 41 | UISupportedInterfaceOrientations 42 | 43 | UIInterfaceOrientationPortrait 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /ble-swift/Logger.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Logger.swift 3 | // ble-swift 4 | // 5 | // Created by Yuan on 14-10-24. 6 | // Copyright (c) 2014年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public class Logger { 12 | 13 | public class func debug(message:AnyObject) { 14 | #if DEBUG 15 | println("\(message)") 16 | #endif 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /ble-swift/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.swift 3 | // ble-swift 4 | // 5 | // Created by Yuan on 14-10-20. 6 | // Copyright (c) 2014年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | class MainViewController: UIViewController, SelectPeripheralProtocol, ConnectPeripheralProtocol, ReadPeripheralProtocol, CreatePeripheralProtocol { 13 | // CSC UUID 14 | // var serviceUUIDString:String = "1816" 15 | // var characteristicUUIDString:String = "2A5B" 16 | // Self defined UUID 17 | var serviceUUIDString:String = "DFABD60D-3291-40ED-8C5B-905252EDD4B8" 18 | var characteristicUUIDString:String = "B6251F0B-3869-4C0D-ACAB-D93F45187E6F" 19 | 20 | @IBOutlet weak var connectBarButton: UIBarButtonItem! 21 | @IBOutlet weak var wheelValueLabel: UILabel! 22 | 23 | var selectedPeripheral : Dictionary = [:] 24 | var isPeripheralConnected:Bool = false 25 | 26 | override func viewDidLoad() { 27 | super.viewDidLoad() 28 | CentralManager.sharedInstance().connectPeripheralDelegate = self 29 | PeripheralManager.sharedInstance().createPeripheralDelegate = self 30 | // Do any additional setup after loading the view, typically from a nib. 31 | } 32 | 33 | override func didReceiveMemoryWarning() { 34 | super.didReceiveMemoryWarning() 35 | // Dispose of any resources that can be recreated. 36 | } 37 | 38 | // MARK: Controller logic 39 | override func prepareForSegue(segue:UIStoryboardSegue, sender:AnyObject!) { 40 | if(segue.identifier == "SelectPeripheral") { 41 | var controller:SelectPeripheralViewController = segue.destinationViewController as SelectPeripheralViewController 42 | controller.delegate = self 43 | } 44 | } 45 | 46 | override func shouldPerformSegueWithIdentifier(identifier:String?, sender:AnyObject?) -> Bool { 47 | if(identifier == "SelectPeripheral") { 48 | if (self.isPeripheralConnected) { 49 | if let peripheral = self.selectedPeripheral.values.array.first { 50 | CentralManager.sharedInstance().cancelPeripheralConnection(peripheral, userClickedCancel: true) 51 | return false 52 | } 53 | } 54 | } 55 | return true 56 | } 57 | 58 | @IBAction func testButtonClicked(sender: AnyObject) { 59 | Logger.debug("testButtonClicked") 60 | // Utils.sendNotification("testButtonClicked", soundName: "") 61 | kill(getpid(), SIGKILL) 62 | } 63 | 64 | // MARK: SelectPeripheralProtocol 65 | func didSelectPeripheral(peripheral:Peripheral) { 66 | Logger.debug("MainViewController#didPeripheralSelected \(peripheral.name)") 67 | selectedPeripheral.removeAll(keepCapacity: false) 68 | selectedPeripheral[peripheral.cbPeripheral] = peripheral 69 | CentralManager.sharedInstance().connectPeripheral(peripheral) 70 | dispatch_async(dispatch_get_main_queue(), { 71 | self.isPeripheralConnected = true 72 | self.title = "Connecting..." 73 | self.connectBarButton.title = "Disconnect" 74 | }) 75 | } 76 | 77 | // MARK: ConnectPeripheralProtocol 78 | func didConnectPeripheral(cbPeripheral: CBPeripheral!) { 79 | Logger.debug("MainViewController#didConnectPeripheral \(cbPeripheral.name)") 80 | dispatch_async(dispatch_get_main_queue(), { 81 | self.title = cbPeripheral.name 82 | }) 83 | // Start to read data 84 | if let peripheral = self.selectedPeripheral[cbPeripheral] { 85 | peripheral.discoverServices([CBUUID(string: serviceUUIDString)], delegate: self) 86 | } 87 | } 88 | 89 | func didDisconnectPeripheral(cbPeripheral: CBPeripheral!, error: NSError!, userClickedCancel: Bool) { 90 | Logger.debug("MainViewController#didDisconnectPeripheral \(cbPeripheral.name)") 91 | let peripheral = self.selectedPeripheral[cbPeripheral] 92 | if (!userClickedCancel && peripheral != nil) { 93 | Logger.debug("Unexpected disconnect, try auto reconnect...") 94 | CentralManager.sharedInstance().connectPeripheral(peripheral!) 95 | dispatch_async(dispatch_get_main_queue(), { 96 | self.title = "Reconnecting..." 97 | }) 98 | } else { 99 | Logger.debug("User clicked disconnect") 100 | dispatch_async(dispatch_get_main_queue(), { 101 | self.isPeripheralConnected = false 102 | self.title = "" 103 | self.connectBarButton.title = "Connect" 104 | self.wheelValueLabel.text = "0" 105 | }) 106 | } 107 | } 108 | 109 | func didRestorePeripheral(peripheral:Peripheral) { 110 | self.didSelectPeripheral(peripheral) 111 | } 112 | 113 | func bluetoothBecomeAvailable() { 114 | 115 | } 116 | 117 | func bluetoothBecomeUnavailable() { 118 | 119 | } 120 | 121 | // MARK: CreatePeripheralProtocol 122 | // Received read request from central, should return value base on "request.characteristic.UUID" value 123 | func didReceiveReadRequest(peripheralManager:CBPeripheralManager!, didReceiveReadRequest request:CBATTRequest!) { 124 | request.value = NSData(data: "ABC".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)!) 125 | peripheralManager.respondToRequest(request, withResult: CBATTError.Success) 126 | } 127 | 128 | // MARK: ReadPeripheralProtocol for CSC (Cycling Speed and Cadence) 129 | var wheelFlag:UInt8 = 0x01 130 | var crankFlag:UInt8 = 0x02 131 | 132 | // Characteristic value is updated, update the UI accordingly 133 | func didUpdateValueForCharacteristic(cbPeripheral: CBPeripheral!, characteristic: CBCharacteristic!, error: NSError!) { 134 | var flags:UInt8 = 0 135 | var wheelRevolutions:UInt32 = 0 136 | var lastWheelEventTime:UInt16 = 0 137 | var crankRevolutions:UInt16 = 0 138 | var lastCrankEventTime:UInt16 = 0 139 | 140 | if (error == nil) { 141 | var data = characteristic.value 142 | // If it's CSC Peripheral Data 143 | if (self.serviceUUIDString == "1816" && self.characteristicUUIDString == "2A5B") { 144 | data.getBytes(&flags, range: NSRange(location: 0, length: 1)) 145 | 146 | if (flags & wheelFlag == wheelFlag) { 147 | data.getBytes(&wheelRevolutions, range: NSRange(location: 1, length: 4)) 148 | data.getBytes(&lastWheelEventTime, range: NSRange(location: 5, length: 2)) 149 | data.getBytes(&crankRevolutions, range: NSRange(location: 7, length: 2)) 150 | data.getBytes(&lastCrankEventTime, range: NSRange(location: 9, length: 2)) 151 | } else if (flags & crankFlag == crankFlag) { 152 | data.getBytes(&crankRevolutions, range: NSRange(location: 1, length: 2)) 153 | data.getBytes(&lastCrankEventTime, range: NSRange(location: 3, length: 2)) 154 | } 155 | 156 | Logger.debug("\(wheelRevolutions)") 157 | 158 | dispatch_async(dispatch_get_main_queue(), { 159 | self.wheelValueLabel.text = String(wheelRevolutions) 160 | }) 161 | } else { 162 | // Else assume it's sample data from bleapp's Peripheral 163 | dispatch_async(dispatch_get_main_queue(), { 164 | self.wheelValueLabel.text = NSString(data: data, encoding: NSUTF8StringEncoding) 165 | }) 166 | } 167 | } else { 168 | Logger.debug("MainViewController#didUpdateValueForCharacteristic error: \(error)") 169 | } 170 | } 171 | 172 | } 173 | -------------------------------------------------------------------------------- /ble-swift/NearbyTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NearbyTableViewController.swift 3 | // ble-swift 4 | // 5 | // Created by Yuan on 15/3/26. 6 | // Copyright (c) 2015年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | class NearbyTableViewController: UITableViewController { 13 | var nearbyPeripherals : [Peripheral] = [] 14 | var historyPeripherals : [Peripheral] = [] 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | // Uncomment the following line to preserve selection between presentations 20 | // self.clearsSelectionOnViewWillAppear = false 21 | 22 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 23 | // self.navigationItem.rightBarButtonItem = self.editButtonItem() 24 | } 25 | 26 | override func viewWillAppear(animated: Bool) { 27 | NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshTable:", name: "afterPeripheralDiscovered", object: nil) 28 | NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshTable:", name: "didUpdateValueForCharacteristic", object: nil) 29 | var appDelegate = UIApplication.sharedApplication().delegate as AppDelegate 30 | appDelegate.stopScanning() 31 | appDelegate.startScanning() 32 | self.updateData() 33 | super.viewWillAppear(animated) 34 | } 35 | 36 | override func viewWillDisappear(animated: Bool) { 37 | NSNotificationCenter.defaultCenter().removeObserver(self) 38 | super.viewWillDisappear(animated) 39 | } 40 | 41 | override func didReceiveMemoryWarning() { 42 | super.didReceiveMemoryWarning() 43 | // Dispose of any resources that can be recreated. 44 | } 45 | 46 | // MARK: - Table view data source 47 | 48 | override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 49 | // Return the number of sections. 50 | return 2 51 | } 52 | 53 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 54 | // Return the number of rows in the section. 55 | if (section == 0) { 56 | return nearbyPeripherals.count 57 | } else { 58 | return historyPeripherals.count 59 | } 60 | } 61 | 62 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 63 | let cell = tableView.dequeueReusableCellWithIdentifier("NearbyCell", forIndexPath: indexPath) as UITableViewCell 64 | var peripheral:Peripheral 65 | if (indexPath.section == 0) { 66 | peripheral = nearbyPeripherals[indexPath.row] 67 | } else { 68 | peripheral = historyPeripherals[indexPath.row] 69 | } 70 | cell.textLabel?.text = peripheral.name 71 | return cell 72 | } 73 | 74 | override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 75 | if (section == 0) { 76 | return "Nearby" 77 | } else { 78 | return "History" 79 | } 80 | } 81 | 82 | /* 83 | // Override to support conditional editing of the table view. 84 | override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { 85 | // Return NO if you do not want the specified item to be editable. 86 | return true 87 | } 88 | */ 89 | 90 | /* 91 | // Override to support editing the table view. 92 | override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { 93 | if editingStyle == .Delete { 94 | // Delete the row from the data source 95 | tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) 96 | } else if editingStyle == .Insert { 97 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 98 | } 99 | } 100 | */ 101 | 102 | /* 103 | // Override to support rearranging the table view. 104 | override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { 105 | 106 | } 107 | */ 108 | 109 | /* 110 | // Override to support conditional rearranging of the table view. 111 | override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { 112 | // Return NO if you do not want the item to be re-orderable. 113 | return true 114 | } 115 | */ 116 | 117 | // MARK: - Navigation 118 | 119 | // In a storyboard-based application, you will often want to do a little preparation before navigation 120 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 121 | // Get the new view controller using [segue destinationViewController]. 122 | // Pass the selected object to the new view controller. 123 | let path = self.tableView.indexPathForSelectedRow()! 124 | let vc : RadarViewController = segue.destinationViewController as RadarViewController 125 | if (path.section == 0) { 126 | vc.peripheral = nearbyPeripherals[path.row] 127 | } else { 128 | vc.peripheral = historyPeripherals[path.row] 129 | } 130 | } 131 | 132 | // MARK: - Private 133 | func refreshTable(notification: NSNotification) { 134 | Logger.debug("NearbyTableViewController#refreshTable for \(notification.name) notification") 135 | self.updateData() 136 | dispatch_async(dispatch_get_main_queue()) { 137 | self.tableView.reloadData() 138 | } 139 | } 140 | 141 | private func updateData() { 142 | nearbyPeripherals.removeAll(keepCapacity: true) 143 | historyPeripherals.removeAll(keepCapacity: true) 144 | var appDelegate = UIApplication.sharedApplication().delegate as AppDelegate 145 | for peripheral:Peripheral in appDelegate.discoveredPeripherals.values.array { 146 | if (peripheral.isNearby) { 147 | nearbyPeripherals.append(peripheral) 148 | } else { 149 | historyPeripherals.append(peripheral) 150 | } 151 | } 152 | } 153 | 154 | } 155 | -------------------------------------------------------------------------------- /ble-swift/Peripheral.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PeripheralController.swift 3 | // ble-swift 4 | // 5 | // Created by Yuan on 14/11/1. 6 | // Copyright (c) 2014年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreBluetooth 11 | 12 | protocol ReadPeripheralProtocol { 13 | var serviceUUIDString:String {get} 14 | var characteristicUUIDString:String {get} 15 | func didUpdateValueForCharacteristic(cbPeripheral: CBPeripheral!, characteristic:CBCharacteristic!, error:NSError!) 16 | } 17 | 18 | public class Peripheral : NSObject, CBPeripheralDelegate { 19 | var readPeripheralDelegate:ReadPeripheralProtocol! 20 | 21 | // INTERNAL 22 | internal let cbPeripheral : CBPeripheral! 23 | 24 | // MARK: Public 25 | public let advertisements : Dictionary! 26 | public let rssi : Int! 27 | 28 | private var _name : String? 29 | public var name : String { 30 | get{ 31 | // iOS does not advertise peripheral name in background 32 | // and even the peripheral is in foreground, the central might still use peripheral's old cached name 33 | // So only use peripheral's name when explicit name is unavialable 34 | if(_name == nil) { 35 | if let name = cbPeripheral.name { 36 | return name 37 | } else { 38 | return "Unknown" 39 | } 40 | } else { 41 | return _name! 42 | } 43 | } 44 | set{ 45 | _name = newValue 46 | } 47 | } 48 | 49 | public var installationId : String? 50 | 51 | public var isNearby = false 52 | 53 | public var hasBeenConnected = false 54 | 55 | public var state : CBPeripheralState { 56 | return self.cbPeripheral.state 57 | } 58 | 59 | public var identifier : NSUUID! { 60 | return self.cbPeripheral.identifier 61 | } 62 | 63 | public init(cbPeripheral:CBPeripheral, advertisements:Dictionary, rssi:Int) { 64 | super.init() 65 | self.cbPeripheral = cbPeripheral 66 | // Fix bug: cbPeripheral.delegate will point to wrong instance because select peripheral screen refresh too fast 67 | // Move to Peripheral#discoverServices 68 | // self.cbPeripheral.delegate = self 69 | self.advertisements = advertisements 70 | self.rssi = rssi 71 | } 72 | 73 | func discoverServices(serviceUUIDs: [CBUUID]!, delegate: ReadPeripheralProtocol!) { 74 | self.cbPeripheral.delegate = self 75 | self.readPeripheralDelegate = delegate 76 | self.cbPeripheral.discoverServices(serviceUUIDs) 77 | } 78 | 79 | // MARK: CBPeripheralDelegate 80 | // peripheral 81 | public func peripheralDidUpdateName(_:CBPeripheral!) { 82 | Logger.debug("Peripheral#peripheralDidUpdateName") 83 | } 84 | 85 | public func peripheral(_:CBPeripheral!, didModifyServices invalidatedServices:[AnyObject]!) { 86 | if let delegate = self.readPeripheralDelegate { 87 | for service:CBService in invalidatedServices as [CBService]! { 88 | if (service.UUID.UUIDString == delegate.serviceUUIDString) { 89 | Logger.debug("Peripheral#didModifyServices \(service)") 90 | CentralManager.sharedInstance().cancelPeripheralConnection(self, userClickedCancel: false) 91 | } 92 | } 93 | } 94 | } 95 | 96 | // services 97 | public func peripheral(peripheral:CBPeripheral!, didDiscoverServices error:NSError!) { 98 | Logger.debug("Peripheral#didDiscoverServices: \(self.name) error: \(error)") 99 | if (error == nil) { 100 | if let delegate:ReadPeripheralProtocol = self.readPeripheralDelegate { 101 | for service:CBService in peripheral.services as [CBService]! { 102 | if (service.UUID.UUIDString == delegate.serviceUUIDString) { 103 | peripheral.discoverCharacteristics([CBUUID(string: delegate.characteristicUUIDString)], forService: service) 104 | } 105 | } 106 | } 107 | } 108 | } 109 | 110 | public func peripheral(_:CBPeripheral!, didDiscoverIncludedServicesForService service:CBService!, error:NSError!) { 111 | Logger.debug("Peripheral#didDiscoverIncludedServicesForService: \(self.name) error: \(error)") 112 | } 113 | 114 | // characteristics 115 | public func peripheral(_:CBPeripheral!, didDiscoverCharacteristicsForService service:CBService!, error:NSError!) { 116 | Logger.debug("Peripheral#didDiscoverCharacteristicsForService: \(self.name) error: \(error)") 117 | if (error == nil) { 118 | if let delegate:ReadPeripheralProtocol = self.readPeripheralDelegate { 119 | for characteristic:CBCharacteristic in service.characteristics as [CBCharacteristic]! { 120 | if (characteristic.UUID.UUIDString == delegate.characteristicUUIDString) { 121 | if (characteristic.properties.rawValue & CBCharacteristicProperties.Notify.rawValue > 0) { 122 | cbPeripheral.setNotifyValue(true, forCharacteristic: characteristic) 123 | } else if (characteristic.properties.rawValue & CBCharacteristicProperties.Read.rawValue > 0) { 124 | cbPeripheral.readValueForCharacteristic(characteristic) 125 | } 126 | } 127 | } 128 | } 129 | } 130 | } 131 | 132 | public func peripheral(_:CBPeripheral!, didUpdateNotificationStateForCharacteristic characteristic:CBCharacteristic!, error:NSError!) { 133 | Logger.debug("Peripheral#didUpdateNotificationStateForCharacteristic error: \(error)") 134 | } 135 | 136 | public func peripheral(peripheral:CBPeripheral!, didUpdateValueForCharacteristic characteristic:CBCharacteristic!, error:NSError!) { 137 | // Logger.debug("Peripheral#didUpdateValueForCharacteristic") 138 | if let delegate:ReadPeripheralProtocol = self.readPeripheralDelegate { 139 | delegate.didUpdateValueForCharacteristic(peripheral, characteristic: characteristic, error: error) 140 | } 141 | } 142 | 143 | public func peripheral(_:CBPeripheral!, didWriteValueForCharacteristic characteristic:CBCharacteristic!, error: NSError!) { 144 | Logger.debug("Peripheral#didWriteValueForCharacteristic error: \(error)") 145 | } 146 | 147 | // descriptors 148 | public func peripheral(_:CBPeripheral!, didDiscoverDescriptorsForCharacteristic characteristic:CBCharacteristic!, error:NSError!) { 149 | Logger.debug("Peripheral#didDiscoverDescriptorsForCharacteristic error: \(error)") 150 | } 151 | 152 | public func peripheral(_:CBPeripheral!, didUpdateValueForDescriptor descriptor:CBDescriptor!, error:NSError!) { 153 | Logger.debug("Peripheral#didUpdateValueForDescriptor error: \(error)") 154 | } 155 | 156 | public func peripheral(_:CBPeripheral!, didWriteValueForDescriptor descriptor:CBDescriptor!, error:NSError!) { 157 | Logger.debug("Peripheral#didWriteValueForDescriptor error: \(error)") 158 | } 159 | 160 | } -------------------------------------------------------------------------------- /ble-swift/PeripheralManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PeripheralManager.swift 3 | // ble-swift 4 | // 5 | // Created by Yuan on 14/11/8. 6 | // Copyright (c) 2014年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreBluetooth 11 | 12 | var thisPeripheralManager : PeripheralManager? 13 | 14 | protocol CreatePeripheralProtocol { 15 | var serviceUUIDString:String {get} 16 | var characteristicUUIDString:String {get} 17 | func didReceiveReadRequest(peripheralManager:CBPeripheralManager!, didReceiveReadRequest request:CBATTRequest!) 18 | } 19 | 20 | public class PeripheralManager : NSObject, CBPeripheralManagerDelegate { 21 | var createPeripheralDelegate:CreatePeripheralProtocol! 22 | private var isAdvertising = false 23 | private let peripheralQueue = dispatch_queue_create("me.xuyuan.ble.peripheral.main", DISPATCH_QUEUE_SERIAL) 24 | internal var cbPeripheralManager : CBPeripheralManager! 25 | 26 | // MARK: Singleton 27 | public class func sharedInstance() -> PeripheralManager { 28 | if thisPeripheralManager == nil { 29 | thisPeripheralManager = PeripheralManager() 30 | } 31 | return thisPeripheralManager! 32 | } 33 | 34 | private override init() { 35 | Logger.debug("PeripheralManager#init") 36 | super.init() 37 | self.cbPeripheralManager = CBPeripheralManager(delegate:self, queue:self.peripheralQueue, options:[CBPeripheralManagerOptionRestoreIdentifierKey:"mainPeripheralManagerIdentifier"]) 38 | } 39 | 40 | // MARK: Public 41 | // advertising 42 | public func startAdvertising() { 43 | if(!isAdvertising) { 44 | Logger.debug("PeripheralManager#startAdvertising") 45 | var advertisementData : [NSObject:AnyObject] = [CBAdvertisementDataServiceUUIDsKey : [CBUUID(string: self.createPeripheralDelegate.serviceUUIDString)]] 46 | self.cbPeripheralManager.startAdvertising(advertisementData) 47 | isAdvertising = true 48 | } 49 | } 50 | 51 | public func stopAdvertising(afterAdvertisingStopped:(()->())? = nil) { 52 | if(isAdvertising) { 53 | Logger.debug("PeripheralManager#stopAdvertising") 54 | self.cbPeripheralManager.stopAdvertising() 55 | isAdvertising = false 56 | } 57 | } 58 | 59 | // MARK: CBPeripheralManagerDelegate 60 | public func peripheralManagerDidUpdateState(peripheral:CBPeripheralManager!) { 61 | switch peripheral.state { 62 | case CBPeripheralManagerState.PoweredOn: 63 | Logger.debug("PeripheralManager#peripheralManagerDidUpdateState: poweredOn") 64 | self.cbPeripheralManager.addService(self.createPeripheralService()) 65 | self.startAdvertising() 66 | case CBPeripheralManagerState.PoweredOff: 67 | Logger.debug("PeripheralManager#peripheralManagerDidUpdateState: poweredOff") 68 | self.stopAdvertising() 69 | case CBPeripheralManagerState.Resetting: 70 | self.stopAdvertising() 71 | case CBPeripheralManagerState.Unsupported: 72 | self.stopAdvertising() 73 | case CBPeripheralManagerState.Unauthorized: 74 | self.stopAdvertising() 75 | case CBPeripheralManagerState.Unknown: 76 | self.stopAdvertising() 77 | default: 78 | self.stopAdvertising() 79 | } 80 | } 81 | 82 | public func peripheralManager(_:CBPeripheralManager!, willRestoreState dict: [NSObject : AnyObject]!) { 83 | if let services:[CBMutableService] = dict[CBPeripheralManagerRestoredStateServicesKey] as [CBMutableService]! { 84 | Logger.debug("PeripheralManager#willRestoreState") 85 | } 86 | } 87 | 88 | public func peripheralManagerDidStartAdvertising(_:CBPeripheralManager!, error:NSError!) { 89 | if error == nil { 90 | Logger.debug("PeripheralManager#peripheralManagerDidStartAdvertising: Success") 91 | } else { 92 | Logger.debug("PeripheralManager#peripheralManagerDidStartAdvertising: Failed '\(error.localizedDescription)'") 93 | } 94 | } 95 | 96 | public func peripheralManager(_:CBPeripheralManager!, didAddService service:CBService!, error:NSError!) { 97 | if error == nil { 98 | Logger.debug("PeripheralManager#didAddService: Success") 99 | } else { 100 | Logger.debug("PeripheralManager#didAddService: Failed '\(error.localizedDescription)'") 101 | } 102 | } 103 | 104 | public func peripheralManager(_:CBPeripheralManager!, central:CBCentral!, didSubscribeToCharacteristic characteristic:CBCharacteristic!) { 105 | Logger.debug("PeripheralManager#didSubscribeToCharacteristic") 106 | } 107 | 108 | public func peripheralManager(_:CBPeripheralManager!, central:CBCentral!, didUnsubscribeFromCharacteristic characteristic:CBCharacteristic!) { 109 | Logger.debug("PeripheralManager#didUnsubscribeFromCharacteristic") 110 | } 111 | 112 | public func peripheralManagerIsReadyToUpdateSubscribers(_:CBPeripheralManager!) { 113 | Logger.debug("PeripheralManager#peripheralManagerIsReadyToUpdateSubscribers") 114 | } 115 | 116 | public func peripheralManager(peripheralManager:CBPeripheralManager!, didReceiveReadRequest request:CBATTRequest!) { 117 | Logger.debug("PeripheralManager#didReceiveReadRequest: chracteracteristic \(request.characteristic.UUID)") 118 | self.createPeripheralDelegate.didReceiveReadRequest(peripheralManager, didReceiveReadRequest: request) 119 | } 120 | 121 | public func peripheralManager(peripheralManager:CBPeripheralManager!, didReceiveWriteRequests requests:[AnyObject]!) { 122 | Logger.debug("PeripheralManager#didReceiveWriteRequests") 123 | } 124 | 125 | // MARK: private 126 | private func createPeripheralService() -> CBMutableService { 127 | var characteristic = CBMutableCharacteristic(type: CBUUID(string: self.createPeripheralDelegate.characteristicUUIDString), properties:CBCharacteristicProperties.Read, value:nil, permissions:CBAttributePermissions.Readable) 128 | var service = CBMutableService(type: CBUUID(string: self.createPeripheralDelegate.serviceUUIDString), primary: true) 129 | service.characteristics = [characteristic] 130 | return service 131 | } 132 | 133 | } -------------------------------------------------------------------------------- /ble-swift/ProfileViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ProfileViewController.swift 3 | // ble-swift 4 | // 5 | // Created by Yuan on 15/3/19. 6 | // Copyright (c) 2015年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Parse 11 | import ParseUI 12 | 13 | class ProfileViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate { 14 | @IBOutlet weak var usernameLabel: UILabel! 15 | 16 | override func viewDidLoad() { 17 | } 18 | 19 | override func viewDidAppear(animated: Bool) { 20 | super.viewDidAppear(animated) 21 | var user = PFUser.currentUser() 22 | if(user == nil) { 23 | showLoginView() 24 | } else { 25 | usernameLabel.text = user.username 26 | } 27 | } 28 | 29 | func logInViewController(logInController: PFLogInViewController!, didLogInUser user: PFUser!) { 30 | updateInstallationWithUser(user) 31 | dismissViewControllerAnimated(true, completion: nil) 32 | } 33 | 34 | func logInViewController(logInController: PFLogInViewController!, didFailToLogInWithError error: NSError!) { 35 | Logger.debug("\(error)") 36 | } 37 | 38 | func logInViewControllerDidCancelLogIn(logInController: PFLogInViewController!) { 39 | Logger.debug("ProfileViewController#logInViewControllerDidCancelLogIn") 40 | } 41 | 42 | func signUpViewController(signUpController: PFSignUpViewController!, didSignUpUser user: PFUser!) { 43 | updateInstallationWithUser(user) 44 | dismissViewControllerAnimated(true, completion: nil) 45 | } 46 | 47 | func signUpViewController(signUpController: PFSignUpViewController!, didFailToSignUpWithError error: NSError!) { 48 | Logger.debug("\(error)") 49 | } 50 | 51 | func signUpViewControllerDidCancelSignUp(signUpController: PFSignUpViewController!) { 52 | Logger.debug("ProfileViewController#signUpViewControllerDidCancelSignUp") 53 | } 54 | 55 | @IBAction func logoutButtonClicked(sender: AnyObject) { 56 | PFUser.logOut() 57 | updateInstallationWithUser(nil) 58 | usernameLabel.text = "" 59 | showLoginView() 60 | } 61 | 62 | @IBAction func quitButtonClicked(sender: AnyObject) { 63 | kill(getpid(), SIGKILL) 64 | } 65 | 66 | private func showLoginView() { 67 | var logInController = PFLogInViewController() 68 | logInController.fields = PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten 69 | var loginLabel = UILabel(frame: CGRectMake(0, 0, 0, 0)) 70 | loginLabel.text = "Flipped" 71 | logInController.logInView.logo = loginLabel 72 | var signupLabel = UILabel(frame: CGRectMake(0, 0, 0, 0)) 73 | signupLabel.text = "Flipped" 74 | logInController.signUpController.signUpView.logo = signupLabel 75 | logInController.delegate = self 76 | logInController.signUpController.delegate = self 77 | self.presentViewController(logInController, animated:true, completion: nil) 78 | } 79 | 80 | private func updateInstallationWithUser(user:PFUser?) { 81 | var currentInstallation = PFInstallation.currentInstallation() 82 | if(user != nil) { 83 | currentInstallation["user"] = user 84 | } else { 85 | currentInstallation.removeObjectForKey("user") 86 | } 87 | currentInstallation.saveInBackgroundWithBlock(nil) 88 | } 89 | 90 | } -------------------------------------------------------------------------------- /ble-swift/RadarViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RadarViewController.swift 3 | // ble-swift 4 | // 5 | // Created by Yuan on 15/4/3. 6 | // Copyright (c) 2015年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | class RadarViewController: UIViewController { 13 | 14 | @IBOutlet weak var rssiLabel: UILabel! 15 | var peripheral : Peripheral? 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | // Do any additional setup after loading the view. 20 | } 21 | 22 | override func viewWillAppear(animated: Bool) { 23 | self.title = peripheral?.name 24 | CentralManager.sharedInstance().stopScanning() 25 | CentralManager.sharedInstance().startScanning(afterPeripheralDiscovered, allowDuplicatesKey: true) 26 | } 27 | 28 | override func viewWillDisappear(animated: Bool) { 29 | CentralManager.sharedInstance().stopScanning() 30 | } 31 | 32 | override func didReceiveMemoryWarning() { 33 | super.didReceiveMemoryWarning() 34 | // Dispose of any resources that can be recreated. 35 | } 36 | 37 | 38 | /* 39 | // MARK: - Navigation 40 | 41 | // In a storyboard-based application, you will often want to do a little preparation before navigation 42 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 43 | // Get the new view controller using segue.destinationViewController. 44 | // Pass the selected object to the new view controller. 45 | } 46 | */ 47 | 48 | func afterPeripheralDiscovered(cbPeripheral:CBPeripheral, advertisementData:NSDictionary, RSSI:NSNumber) { 49 | if (peripheral?.cbPeripheral == cbPeripheral) { 50 | // Bypass 127. The disconnected case will be handled by other logic 51 | if (RSSI != 127) { // 127 means disconnected, which sometimes is not true 52 | dispatch_async(dispatch_get_main_queue()) { 53 | self.rssiLabel.text = RSSI.stringValue 54 | } 55 | } 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /ble-swift/SelectPeripheralViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SelectPeripheralViewController.swift 3 | // ble-swift 4 | // 5 | // Created by Yuan on 14-10-26. 6 | // Copyright (c) 2014年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | protocol SelectPeripheralProtocol { 13 | func didSelectPeripheral(peripheral:Peripheral) 14 | } 15 | 16 | class SelectPeripheralViewController: UITableViewController { 17 | var delegate:SelectPeripheralProtocol! 18 | var discoveredPeripherals : Dictionary = [:] 19 | var tempPeripherals : Dictionary = [:] 20 | var allowDuplicatesKey : Bool = true 21 | 22 | private var timer:NSTimer! 23 | 24 | required init(coder aDecoder: NSCoder) { 25 | super.init(coder:aDecoder) 26 | } 27 | 28 | override func viewDidLoad() { 29 | super.viewDidLoad() 30 | // Do any additional setup after loading the view, typically from a nib. 31 | } 32 | 33 | override func viewWillAppear(animated: Bool) { 34 | CentralManager.sharedInstance().startScanning(afterPeripheralDiscovered, allowDuplicatesKey: allowDuplicatesKey) 35 | timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("refreshPeripherals"), userInfo: nil, repeats: true) 36 | } 37 | 38 | override func viewWillDisappear(animated: Bool) { 39 | CentralManager.sharedInstance().stopScanning() 40 | timer.invalidate() 41 | timer = nil 42 | } 43 | 44 | override func didReceiveMemoryWarning() { 45 | super.didReceiveMemoryWarning() 46 | // Dispose of any resources that can be recreated. 47 | } 48 | 49 | // MARK: UITableViewDataSource 50 | override func numberOfSectionsInTableView(tableView:UITableView) -> Int { 51 | return 1 52 | } 53 | 54 | override func tableView(_:UITableView, numberOfRowsInSection section:Int) -> Int { 55 | return self.discoveredPeripherals.values.array.count 56 | } 57 | 58 | override func tableView(tableView:UITableView, cellForRowAtIndexPath indexPath:NSIndexPath) -> UITableViewCell { 59 | let cell = tableView.dequeueReusableCellWithIdentifier("PeripheralCell", forIndexPath: indexPath) as UITableViewCell 60 | let peripheral = self.discoveredPeripherals.values.array[indexPath.row] 61 | cell.textLabel!.text = peripheral.name 62 | return cell 63 | } 64 | 65 | // MARK: UITableViewDelegate 66 | override func tableView(tableView:UITableView, didSelectRowAtIndexPath indexPath:NSIndexPath) { 67 | self.navigationController?.popViewControllerAnimated(true) 68 | self.delegate.didSelectPeripheral(discoveredPeripherals.values.array[indexPath.row]) 69 | } 70 | 71 | // MARK: Private 72 | private func afterPeripheralDiscovered(cbPeripheral:CBPeripheral, advertisementData:NSDictionary, RSSI:NSNumber) { 73 | if (self.tempPeripherals[cbPeripheral] == nil) { 74 | let peripheral = Peripheral(cbPeripheral:cbPeripheral, advertisements:advertisementData, rssi:RSSI.integerValue) 75 | // Logger.debug("SelectPeripheralViewController#afterPeripheralDiscovered: Store peripheral \(peripheral.name)") 76 | self.tempPeripherals[cbPeripheral] = peripheral 77 | } else { 78 | // Logger.debug("SelectPeripheralViewController#afterPeripheralDiscovered: Already stored peripheral \(cbPeripheral.name)") 79 | } 80 | } 81 | 82 | // Not used 83 | private func unpackAdvertisements(advertDictionary:NSDictionary!) -> Dictionary { 84 | Logger.debug("SelectPeripheralViewController#unpackAdvertisements found \(advertDictionary.count) advertisements") 85 | var advertisements = Dictionary() 86 | func addKey(key:String, andValue value:AnyObject) -> () { 87 | if value is NSString { 88 | advertisements[key] = (value as? String) 89 | } else if value is CBUUID { 90 | advertisements[key] = value.UUIDString 91 | } else { 92 | advertisements[key] = value.stringValue 93 | } 94 | Logger.debug("SelectPeripheralViewController#unpackAdvertisements key:\(key), value:\(advertisements[key])") 95 | } 96 | if advertDictionary != nil { 97 | for keyObject : AnyObject in advertDictionary.allKeys { 98 | let key = keyObject as String 99 | let value : AnyObject! = advertDictionary.objectForKey(keyObject) 100 | if value is NSArray { 101 | for v : AnyObject in (value as NSArray) { 102 | // TODO: Bug, duplicate key will be overrided 103 | addKey(key, andValue:v) 104 | } 105 | } else { 106 | addKey(key, andValue:value) 107 | } 108 | } 109 | } 110 | Logger.debug("SelectPeripheralViewController#unpackAdvertisements unpacked \(advertisements.count) advertisements") 111 | return advertisements 112 | } 113 | 114 | func refreshPeripherals() { 115 | discoveredPeripherals = tempPeripherals // Copy by value 116 | if (allowDuplicatesKey) { 117 | // Empty and restart collecting 118 | tempPeripherals = [:] 119 | } 120 | dispatch_async(dispatch_get_main_queue(), self.tableView.reloadData) 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /ble-swift/Utilities/Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Utils.swift 3 | // ble-swift 4 | // 5 | // Created by Yuan on 14-10-20. 6 | // Copyright (c) 2014年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class Utils { 13 | 14 | class func sendNotification(note:String, soundName:String) { 15 | var notification = UILocalNotification() 16 | notification.fireDate = NSDate(timeIntervalSinceNow: 1) 17 | notification.hasAction = false 18 | notification.alertBody = note 19 | notification.timeZone = NSTimeZone.defaultTimeZone() 20 | notification.soundName = soundName 21 | UIApplication.sharedApplication().scheduleLocalNotification(notification) 22 | } 23 | 24 | class func showAlert(message:String) { 25 | var alert = UIAlertView() 26 | alert.title = "Notification" 27 | alert.message = message 28 | alert.addButtonWithTitle("OK") 29 | alert.show() 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /ble-swiftTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | xuyuan.me.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ble-swiftTests/ble_swiftTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ble_swiftTests.swift 3 | // ble-swiftTests 4 | // 5 | // Created by Yuan on 14-10-20. 6 | // Copyright (c) 2014年 xuyuanme. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class ble_swiftTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------