upgrade Facebook libraries
This commit is contained in:
1 parent
451fc6aa7f
commit
060efc0c83
72 files changed
+6811
-5623
No files matched your search
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
//
|
||||
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||
// copy, modify, and distribute this software in source code or binary form for use
|
||||
// in connection with the web services and APIs provided by Facebook.
|
||||
//
|
||||
// As with any software that integrates with the Facebook platform, your use of
|
||||
// this software is subject to the Facebook Developer Principles and Policies
|
||||
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||
// included in all copies or substantial portions of the software.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
#import <FBSDKPlacesKit/FBSDKPlacesManager.h>
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
//
|
||||
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||
// copy, modify, and distribute this software in source code or binary form for use
|
||||
// in connection with the web services and APIs provided by Facebook.
|
||||
//
|
||||
// As with any software that integrates with the Facebook platform, your use of
|
||||
// this software is subject to the Facebook Developer Principles and Policies
|
||||
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||
// included in all copies or substantial portions of the software.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
These are the fields currently exposed by FBSDKPlacesKit. They map to the fields on
|
||||
Place objects returned by the Graph API, which can be found here:
|
||||
https://developers.facebook.com/docs/places. Should fields be added to the Graph API in
|
||||
the future, you can use strings found in the online documenation in addition to
|
||||
these string constants.
|
||||
*/
|
||||
|
||||
/**
|
||||
Field Key for information about the Place.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyAbout;
|
||||
|
||||
/**
|
||||
Field Key for AppLinks for the Place.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyAppLinks;
|
||||
|
||||
/**
|
||||
Field Key for the Place's categories.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyCategories;
|
||||
|
||||
/**
|
||||
Field Key for the number of checkins at the Place.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyCheckins;
|
||||
|
||||
/**
|
||||
Field Key for the confidence level for a current place estimate candidate.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyConfidence;
|
||||
|
||||
/**
|
||||
Field Key for the Place's cover photo. Note that this is not the actual photo data,
|
||||
but rather URLs and other metadata.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyCoverPhoto;
|
||||
|
||||
/**
|
||||
Field Key for the description of the Place.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyDescription;
|
||||
|
||||
/**
|
||||
Field Key for the social sentence and like count information for this place. This is
|
||||
the same information used for the Like button.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyEngagement;
|
||||
|
||||
/**
|
||||
Field Key for hour ranges for when the Place is open. Each day can have two different
|
||||
hours ranges. The keys in the dictionary are in the form of {day}_{number}_{status}.
|
||||
{day} should be the first 3 characters of the day of the week, {number} should be
|
||||
either 1 or 2 to allow for the two different hours ranges per day. {status} should be
|
||||
either open or close, to delineate the start or end of a time range. An example would
|
||||
be mon_1_open with value 17:00 and mon_1_close with value 21:15 which would represent
|
||||
a single opening range of 5 PM to 9:15 PM on Mondays. You can find an example of hours
|
||||
being parsed out in the Sample App.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyHours;
|
||||
|
||||
/**
|
||||
Field Key for a value indicating whether this place is always open.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyIsAlwaysOpen;
|
||||
|
||||
/**
|
||||
Field Key for a value indicating whether this place is permanently closed.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyIsPermanentlyClosed;
|
||||
|
||||
/**
|
||||
Pages with a large number of followers can be manually verified by Facebook as having an
|
||||
authentic identity. This field indicates whether the page is verified by this process.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyIsVerified;
|
||||
|
||||
/**
|
||||
Field Key for address and latitude/longitude information for the place.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyLocation;
|
||||
|
||||
/**
|
||||
Field Key for a link to Place's Facebook page.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyLink;
|
||||
|
||||
/**
|
||||
Field Key for the name of the place.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyName;
|
||||
|
||||
/**
|
||||
Field Key for the overall page rating based on rating surveys from users on a scale
|
||||
from 1-5. This value is normalized, and is not guaranteed to be a strict average of
|
||||
user ratings.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyOverallStarRating;
|
||||
|
||||
/**
|
||||
Field Key for the Facebook Page information.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyPage;
|
||||
|
||||
/**
|
||||
Field Key for PageParking information for the Place.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyParking;
|
||||
|
||||
/**
|
||||
Field Key for available payment options.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyPaymentOptions;
|
||||
|
||||
/**
|
||||
Field Key for the unique Facebook ID of the place.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyPlaceID;
|
||||
|
||||
/**
|
||||
Field Key for the Place's phone number.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyPhone;
|
||||
|
||||
/**
|
||||
Field Key for the Place's photos. Note that this is not the actual photo data, but
|
||||
rather URLs and other metadata.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyPhotos;
|
||||
|
||||
/**
|
||||
Field Key for the price range of the business, expressed as a string. Applicable to
|
||||
Restaurants or Nightlife. Can be one of $ (0-10), $$ (10-30), $$$ (30-50), $$$$ (50+),
|
||||
or Unspecified.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyPriceRange;
|
||||
|
||||
/**
|
||||
Field Key for the Place's profile photo. Note that this is not the actual photo data,
|
||||
but rather URLs and other metadata.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyProfilePhoto;
|
||||
|
||||
/**
|
||||
Field Key for the number of ratings for the place.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyRatingCount;
|
||||
|
||||
/**
|
||||
Field Key for restaurant services e.g: delivery, takeout.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyRestaurantServices;
|
||||
|
||||
/**
|
||||
Field Key for restaurant specialties.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyRestaurantSpecialties;
|
||||
|
||||
/**
|
||||
Field Key for the address in a single line.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeySingleLineAddress;
|
||||
|
||||
/**
|
||||
Field Key for the string of the Place's website URL.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyWebsite;
|
||||
|
||||
/**
|
||||
Field Key for the Workflows.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesFieldKeyWorkflows;
|
||||
|
||||
/**
|
||||
Response Key for the place's city field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyCity;
|
||||
|
||||
/**
|
||||
Response Key for the place's city ID field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyCityID;
|
||||
|
||||
/**
|
||||
Response Key for the place's country field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyCountry;
|
||||
|
||||
/**
|
||||
Response Key for the place's country code field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyCountryCode;
|
||||
|
||||
/**
|
||||
Response Key for the place's latitude field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyLatitude;
|
||||
|
||||
/**
|
||||
Response Key for the place's longitude field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyLongitude;
|
||||
|
||||
/**
|
||||
Response Key for the place's region field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyRegion;
|
||||
|
||||
/**
|
||||
Response Key for the place's region ID field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyRegionID;
|
||||
|
||||
/**
|
||||
Response Key for the place's state field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyState;
|
||||
|
||||
/**
|
||||
Response Key for the place's street field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyStreet;
|
||||
|
||||
/**
|
||||
Response Key for the place's zip code field.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyZip;
|
||||
|
||||
/**
|
||||
Response Key for the categories that this place matched.
|
||||
To be used on the search request if the categories parameter is specified.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyMatchedCategories;
|
||||
|
||||
/**
|
||||
Response Key for the photo source dictionary.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyPhotoSource;
|
||||
|
||||
/**
|
||||
Response Key for response data.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyData;
|
||||
|
||||
/**
|
||||
Response Key for a URL.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesResponseKeyUrl;
|
||||
|
||||
/**
|
||||
Parameter Key for the current place summary.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesParameterKeySummary;
|
||||
|
||||
/**
|
||||
Summary Key for the current place tracking ID.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKPlacesSummaryKeyTracking;
|
||||
|
||||
/**
|
||||
The level of confidence the Facebook SDK has that a Place is the correct one for the
|
||||
user's current location.
|
||||
|
||||
- FBSDKPlaceLocationConfidenceNotApplicable: Used to indicate that any level is
|
||||
acceptable as a minimum threshold
|
||||
- FBSDKPlaceLocationConfidenceLow: Low confidence level.
|
||||
- FBSDKPlaceLocationConfidenceMedium: Medium confidence level.
|
||||
- FBSDKPlaceLocationConfidenceHigh: High confidence level.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
FBSDKPlaceLocationConfidenceNotApplicable,
|
||||
FBSDKPlaceLocationConfidenceLow,
|
||||
FBSDKPlaceLocationConfidenceMedium,
|
||||
FBSDKPlaceLocationConfidenceHigh
|
||||
} FBSDKPlaceLocationConfidence;
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
//
|
||||
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||
// copy, modify, and distribute this software in source code or binary form for use
|
||||
// in connection with the web services and APIs provided by Facebook.
|
||||
//
|
||||
// As with any software that integrates with the Facebook platform, your use of
|
||||
// this software is subject to the Facebook Developer Principles and Policies
|
||||
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||
// included in all copies or substantial portions of the software.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include "FBSDKPlacesKitConstants.h"
|
||||
|
||||
NSString *const FBSDKPlacesFieldKeyAbout = @"about";
|
||||
NSString *const FBSDKPlacesFieldKeyAppLinks = @"app_links";
|
||||
NSString *const FBSDKPlacesFieldKeyCategories = @"category_list";
|
||||
NSString *const FBSDKPlacesFieldKeyCheckins = @"checkins";
|
||||
NSString *const FBSDKPlacesFieldKeyConfidence = @"confidence_level";
|
||||
NSString *const FBSDKPlacesFieldKeyCoverPhoto = @"cover";
|
||||
NSString *const FBSDKPlacesFieldKeyDescription = @"description";
|
||||
NSString *const FBSDKPlacesFieldKeyEngagement = @"engagement";
|
||||
NSString *const FBSDKPlacesFieldKeyHours = @"hours";
|
||||
NSString *const FBSDKPlacesFieldKeyIsAlwaysOpen = @"is_always_open";
|
||||
NSString *const FBSDKPlacesFieldKeyIsPermanentlyClosed = @"is_permanently_closed";
|
||||
NSString *const FBSDKPlacesFieldKeyIsVerified = @"is_verified";
|
||||
NSString *const FBSDKPlacesFieldKeyLink = @"link";
|
||||
NSString *const FBSDKPlacesFieldKeyLocation = @"location";
|
||||
NSString *const FBSDKPlacesFieldKeyName = @"name";
|
||||
NSString *const FBSDKPlacesFieldKeyOverallStarRating = @"overall_star_rating";
|
||||
NSString *const FBSDKPlacesFieldKeyPlaceID = @"id";
|
||||
NSString *const FBSDKPlacesFieldKeyPage = @"page";
|
||||
NSString *const FBSDKPlacesFieldKeyParking = @"parking";
|
||||
NSString *const FBSDKPlacesFieldKeyPaymentOptions = @"payment_options";
|
||||
NSString *const FBSDKPlacesFieldKeyPhone = @"phone";
|
||||
NSString *const FBSDKPlacesFieldKeyProfilePhoto = @"picture";
|
||||
NSString *const FBSDKPlacesFieldKeyPhotos = @"photos";
|
||||
NSString *const FBSDKPlacesFieldKeyPriceRange = @"price_range";
|
||||
NSString *const FBSDKPlacesFieldKeyRatingCount = @"rating_count";
|
||||
NSString *const FBSDKPlacesFieldKeyRestaurantServices = @"restaurant_services";
|
||||
NSString *const FBSDKPlacesFieldKeyRestaurantSpecialties = @"restaurant_specialties";
|
||||
NSString *const FBSDKPlacesFieldKeySingleLineAddress = @"single_line_address";
|
||||
NSString *const FBSDKPlacesFieldKeyWebsite = @"website";
|
||||
NSString *const FBSDKPlacesFieldKeyWorkflows = @"workflows";
|
||||
|
||||
NSString *const FBSDKPlacesResponseKeyCity = @"city";
|
||||
NSString *const FBSDKPlacesResponseKeyCityID = @"city_id";
|
||||
NSString *const FBSDKPlacesResponseKeyCountry = @"country";
|
||||
NSString *const FBSDKPlacesResponseKeyCountryCode = @"country_code";
|
||||
|
||||
NSString *const FBSDKPlacesResponseKeyLatitude = @"latitude";
|
||||
NSString *const FBSDKPlacesResponseKeyLongitude = @"longitude";
|
||||
|
||||
NSString *const FBSDKPlacesResponseKeyRegion = @"region";
|
||||
NSString *const FBSDKPlacesResponseKeyRegionID = @"region_id";
|
||||
NSString *const FBSDKPlacesResponseKeyState = @"state";
|
||||
NSString *const FBSDKPlacesResponseKeyStreet = @"street";
|
||||
NSString *const FBSDKPlacesResponseKeyZip = @"zip";
|
||||
|
||||
NSString *const FBSDKPlacesResponseKeyMatchedCategories = @"matched_categories";
|
||||
|
||||
NSString *const FBSDKPlacesResponseKeyPhotoSource = @"source";
|
||||
NSString *const FBSDKPlacesResponseKeyData = @"data";
|
||||
NSString *const FBSDKPlacesResponseKeyUrl = @"url";
|
||||
|
||||
NSString *const FBSDKPlacesParameterKeySummary = @"summary";
|
||||
NSString *const FBSDKPlacesSummaryKeyTracking = @"tracking";
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
//
|
||||
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||
// copy, modify, and distribute this software in source code or binary form for use
|
||||
// in connection with the web services and APIs provided by Facebook.
|
||||
//
|
||||
// As with any software that integrates with the Facebook platform, your use of
|
||||
// this software is subject to the Facebook Developer Principles and Policies
|
||||
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||
// included in all copies or substantial portions of the software.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <FBSDKCoreKit/FBSDKCoreKit.h>
|
||||
|
||||
#import "FBSDKPlacesKitConstants.h"
|
||||
|
||||
/**
|
||||
Completion block for aysnchronous place request generation.
|
||||
|
||||
@param graphRequest An `FBSDKGraphRequest` with the parameters supplied to the
|
||||
original method call.
|
||||
|
||||
@param location A CLLocation representing the current location of the device at the time
|
||||
of the method call, which you can cache for later use.
|
||||
|
||||
@param error An error indicating a failure in a location services request.
|
||||
*/
|
||||
typedef void (^FBSDKPlaceGraphRequestCompletion)(FBSDKGraphRequest *_Nullable graphRequest, CLLocation *_Nullable location, NSError *_Nullable error);
|
||||
|
||||
/**
|
||||
Completion block for aysnchronous current place request generation.
|
||||
|
||||
@param graphRequest An `FBSDKGraphRequest` with the parameters supplied to the
|
||||
original method call.
|
||||
|
||||
@param error An error indicating a failure in a location services request.
|
||||
*/
|
||||
typedef void (^FBSDKCurrentPlaceGraphRequestCompletion)(FBSDKGraphRequest *_Nullable graphRequest, NSError *_Nullable error);
|
||||
|
||||
/**
|
||||
`FBSDKPlacesManager` provides methods for searching for nearby places, as well as for
|
||||
determining the current place where a person might be.
|
||||
|
||||
To use some features of the `FBSDKPlacesManager`, your app must be configured to allow
|
||||
either the `CoreLocation` permission for `kCLAuthorizationStatusAuthorizedWhenInUse`,
|
||||
or for `kCLAuthorizationStatusAuthorizedAlways`. For information about enabling these
|
||||
for your app, see:
|
||||
https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html.
|
||||
*/
|
||||
@interface FBSDKPlacesManager : NSObject
|
||||
|
||||
|
||||
/**
|
||||
Method for generating a graph request for searching the Places Graph using the device's
|
||||
current location. This is an asynchronous call, due to the need to fetch the current
|
||||
location from the device.
|
||||
|
||||
@param searchTerm The term to search for in the Places Graph.
|
||||
|
||||
@param categories The categories for the place. Each string in this array must be a
|
||||
category recognized by the SDK. See `FBSDKPlacesKitConstants.h` for the categories
|
||||
exposed by the SDK, and see https://developers.facebook.com/docs/places/web/search#categories
|
||||
for the most up to date list.
|
||||
|
||||
@param fields A list of fields that you might want the request to return. See
|
||||
`FBSDKPlacesKitConstants.h` for the fields exposed by the SDK, and see
|
||||
https://developers.facebook.com/docs/places/fields" for the most up to date list.
|
||||
|
||||
@param distance The search radius. For an unlimited radius, use 0.
|
||||
|
||||
@param cursor A pagination cursor.
|
||||
|
||||
@param completion An `FBSDKPlaceGraphRequestCompletion` block. Note that this block will
|
||||
return the location, which you can choose to cache and use on calls to the synchronous
|
||||
`placesGraphRequestForLocation` method.
|
||||
*/
|
||||
- (void)generatePlaceSearchRequestForSearchTerm:(nullable NSString *)searchTerm
|
||||
categories:(nullable NSArray<NSString *> *)categories
|
||||
fields:(nullable NSArray<NSString *> *)fields
|
||||
distance:(CLLocationDistance)distance
|
||||
cursor:(nullable NSString *)cursor
|
||||
completion:(nonnull FBSDKPlaceGraphRequestCompletion)completion;
|
||||
|
||||
/**
|
||||
Method for generating a graph request for searching the Places API.
|
||||
|
||||
@param location The location for the search. If you do not wish to provide a location,
|
||||
you must provide a search term.
|
||||
|
||||
@param searchTerm The term to search the Places Graph for.
|
||||
|
||||
@param categories The categories of the place. Each string in this array must be a
|
||||
category recognized by the SDK. See `FBSDKPlacesKitConstants.h` for the categories
|
||||
exposed by the SDK, and see https://developers.facebook.com/docs/places/web/search#categories
|
||||
for the most up to date list.
|
||||
|
||||
@param fields A list of fields that you might want the request to return. See
|
||||
`FBSDKPlacesKitConstants.h` for the fields exposed by the SDK, and see https://developers.facebook.com/docs/places/fields
|
||||
for the most up to date list.
|
||||
|
||||
@param distance The search radius. For an unlimited radius, use 0.
|
||||
|
||||
@param cursor A pagination cursor
|
||||
|
||||
@return An `FBSDKGraphRequest` for the given parameters.
|
||||
*/
|
||||
- (nullable FBSDKGraphRequest *)placeSearchRequestForLocation:(nullable CLLocation *)location
|
||||
searchTerm:(nullable NSString *)searchTerm
|
||||
categories:(nullable NSArray<NSString *> *)categories
|
||||
fields:(nullable NSArray<NSString *> *)fields
|
||||
distance:(CLLocationDistance)distance
|
||||
cursor:(nullable NSString *)cursor;
|
||||
|
||||
/**
|
||||
Method for generating a graph request to query for places the device is likely
|
||||
located in. This is an asynchronous call, due to the need to fetch the current location
|
||||
from the device. Note that the results of the graph request are improved if the user has
|
||||
both Wi-Fi and Bluetooth enabled.
|
||||
|
||||
@param minimumConfidence The Minimum Confidence level place estimate candidates must meet.
|
||||
|
||||
@param fields A list of fields that you might want the request to return. See
|
||||
`FBSDKPlacesKitConstants.h` for the fields exposed by the SDK, and see https://developers.facebook.com/docs/places/fields
|
||||
for the most up to date list.
|
||||
|
||||
@param completion A `FBSDKCurrentPlaceGraphRequestCompletion` block, that contains the graph request.
|
||||
*/
|
||||
- (void)generateCurrentPlaceRequestWithMinimumConfidenceLevel:(FBSDKPlaceLocationConfidence)minimumConfidence
|
||||
fields:(nullable NSArray<NSString *> *)fields
|
||||
completion:(nonnull FBSDKCurrentPlaceGraphRequestCompletion)completion;
|
||||
|
||||
/**
|
||||
Method for generating a graph request to query for places the device is likely
|
||||
located in. This method allows the user to pass in a CLLocation, as the above method
|
||||
can be real-world slow at obtaining a location from device (on the order of multiple
|
||||
seconds). This is still an asynchronous call, as the bluetooth scan still needs to
|
||||
happen, however it is relatively fast (0.5 seconds). Note that the results of the
|
||||
graph request are improved if the user has both Wi-Fi and Bluetooth enabled.
|
||||
|
||||
@param currentLocation The current location of the device. If the location passed in here
|
||||
isn't actually the current location, accuracy of results will be diminished.
|
||||
|
||||
@param minimumConfidence The Minimum Confidence level place estimate candidates must meet.
|
||||
|
||||
@param fields A list of fields that you might want the request to return. See
|
||||
`FBSDKPlacesKitConstants.h` for the fields exposed by the SDK, and see https://developers.facebook.com/docs/places/fields
|
||||
for the most up to date list.
|
||||
|
||||
@param completion A `FBSDKCurrentPlaceGraphRequestCompletion` block, that contains the graph request.
|
||||
*/
|
||||
- (void)generateCurrentPlaceRequestForCurrentLocation:(nonnull CLLocation *)currentLocation
|
||||
withMinimumConfidenceLevel:(FBSDKPlaceLocationConfidence)minimumConfidence
|
||||
fields:(nullable NSArray<NSString *> *)fields
|
||||
completion:(nonnull FBSDKCurrentPlaceGraphRequestCompletion)completion;
|
||||
|
||||
/**
|
||||
Method for generating a graph request to provide feedback to the Places Graph about
|
||||
the accuracy of current place estimate candidates. We'd very much appreciate it if
|
||||
you'd give us feedback about our current place results. If a user indicates that a place
|
||||
returned by a current place estimate either is, or is not where they currently are,
|
||||
then this method generates a graph request to allow you to pass that feedback back to us.
|
||||
|
||||
@param placeID The place ID returned by the current place request.
|
||||
|
||||
@param tracking The tracking value returned by the current place request.
|
||||
|
||||
@param wasHere A boolean value indicating whether the user is actually at the place.
|
||||
|
||||
@return An `FBSDKGraphRequest` for the given parameters.
|
||||
*/
|
||||
- (nonnull FBSDKGraphRequest *)currentPlaceFeedbackRequestForPlaceID:(nonnull NSString *)placeID
|
||||
tracking:(nonnull NSString *)tracking
|
||||
wasHere:(BOOL)wasHere;
|
||||
|
||||
/**
|
||||
Method for generating a graph request to fetch additional information for a given place.
|
||||
|
||||
@param placeID The ID of the place.
|
||||
|
||||
@param fields A list of fields that you might want the request to return. See
|
||||
`FBSDKPlacesKitConstants.h` for the fields exposed by the SDK, and see https://developers.facebook.com/docs/places/fields
|
||||
for the most up to date list.
|
||||
|
||||
@return An `FBSDKGraphRequest` for the given parameters.
|
||||
*/
|
||||
- (nonnull FBSDKGraphRequest *)placeInfoRequestForPlaceID:(nonnull NSString *)placeID
|
||||
fields:(nullable NSArray<NSString *> *)fields;
|
||||
|
||||
|
||||
@end
|
||||
+328
@@ -0,0 +1,328 @@
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
//
|
||||
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||
// copy, modify, and distribute this software in source code or binary form for use
|
||||
// in connection with the web services and APIs provided by Facebook.
|
||||
//
|
||||
// As with any software that integrates with the Facebook platform, your use of
|
||||
// this software is subject to the Facebook Developer Principles and Policies
|
||||
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||
// included in all copies or substantial portions of the software.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#import "FBSDKPlacesManager.h"
|
||||
|
||||
#import <SystemConfiguration/CaptiveNetwork.h>
|
||||
|
||||
#import "FBSDKPlacesBluetoothScanner.h"
|
||||
|
||||
static NSString *const ParameterKeyFields = @"fields";
|
||||
|
||||
typedef void (^FBSDKLocationRequestCompletion)(CLLocation *_Nullable location, NSError *_Nullable error);
|
||||
|
||||
@interface FBSDKPlacesManager() <CLLocationManagerDelegate>
|
||||
|
||||
@property (nonatomic, strong) CLLocationManager *locationManager;
|
||||
@property (atomic, strong) NSMutableArray <FBSDKLocationRequestCompletion> *locationCompletionBlocks;
|
||||
|
||||
@property (nonatomic, strong) FBSDKPlacesBluetoothScanner *bluetoothScanner;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKPlacesManager
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_locationManager = [CLLocationManager new];
|
||||
_locationManager.delegate = self;
|
||||
_locationCompletionBlocks = [NSMutableArray new];
|
||||
_bluetoothScanner = [FBSDKPlacesBluetoothScanner new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Place Search
|
||||
|
||||
- (void)generatePlaceSearchRequestForSearchTerm:(NSString *)searchTerm
|
||||
categories:(NSArray<NSString *> *)categories
|
||||
fields:(NSArray<NSString *> *)fields
|
||||
distance:(CLLocationDistance)distance
|
||||
cursor:(NSString *)cursor
|
||||
completion:(FBSDKPlaceGraphRequestCompletion)completion
|
||||
{
|
||||
__weak FBSDKPlacesManager *weakSelf = self;
|
||||
[self.locationCompletionBlocks addObject:^void (CLLocation *location, NSError *error) {
|
||||
if (!error) {
|
||||
FBSDKGraphRequest *request = [weakSelf placeSearchRequestForLocation:location searchTerm:searchTerm categories:categories fields:fields distance:distance cursor:cursor];
|
||||
completion(request, location, nil);
|
||||
}
|
||||
else {
|
||||
completion(nil, nil, error);
|
||||
}
|
||||
}];
|
||||
|
||||
[self.locationManager requestLocation];
|
||||
}
|
||||
|
||||
- (FBSDKGraphRequest *)placeSearchRequestForLocation:(CLLocation *)location
|
||||
searchTerm:(NSString *)searchTerm
|
||||
categories:(NSArray<NSString *> *)categories
|
||||
fields:(NSArray<NSString *> *)fields
|
||||
distance:(CLLocationDistance)distance
|
||||
cursor:(NSString *)cursor
|
||||
{
|
||||
if (!location && !searchTerm) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSMutableDictionary *parameters = [@{@"type" : @"place"} mutableCopy];
|
||||
|
||||
if (searchTerm) {
|
||||
parameters[@"q"] = searchTerm;
|
||||
}
|
||||
if (categories) {
|
||||
parameters[@"categories"] = [self _jsonStringForObject:categories];
|
||||
}
|
||||
if (location) {
|
||||
parameters[@"center"] = [NSString stringWithFormat:@"%f,%f", location.coordinate.latitude, location.coordinate.longitude];
|
||||
}
|
||||
if (distance > 0) {
|
||||
parameters[@"distance"] = @(distance);
|
||||
}
|
||||
if (fields) {
|
||||
parameters[ParameterKeyFields] = [fields componentsJoinedByString:@","];
|
||||
}
|
||||
|
||||
return [[FBSDKGraphRequest alloc]
|
||||
initWithGraphPath:@"search"
|
||||
parameters:parameters
|
||||
tokenString:self._tokenString
|
||||
version:nil
|
||||
HTTPMethod:nil];
|
||||
}
|
||||
|
||||
- (void)generateCurrentPlaceRequestWithMinimumConfidenceLevel:(FBSDKPlaceLocationConfidence)minimumConfidence
|
||||
fields:(NSArray<NSString *> *)fields
|
||||
completion:(FBSDKCurrentPlaceGraphRequestCompletion)completion
|
||||
{
|
||||
|
||||
dispatch_group_t locationAndBeaconsGroup = dispatch_group_create();
|
||||
|
||||
__block CLLocation *currentLocation = nil;
|
||||
__block NSError *locationError = nil;
|
||||
|
||||
__block NSArray<FBSDKBluetoothBeacon *> *currentBeacons = nil;
|
||||
|
||||
dispatch_group_enter(locationAndBeaconsGroup);
|
||||
[self.locationCompletionBlocks addObject:^void (CLLocation *location, NSError *error) {
|
||||
currentLocation = location;
|
||||
locationError = error;
|
||||
dispatch_group_leave(locationAndBeaconsGroup);
|
||||
}];
|
||||
|
||||
[self.locationManager requestLocation];
|
||||
|
||||
dispatch_group_enter(locationAndBeaconsGroup);
|
||||
[self.bluetoothScanner scanForBeaconsWithCompletion:^(NSArray<FBSDKBluetoothBeacon *> * _Nullable beacons) {
|
||||
currentBeacons = beacons;
|
||||
dispatch_group_leave(locationAndBeaconsGroup);
|
||||
}];
|
||||
|
||||
dispatch_group_notify(locationAndBeaconsGroup, dispatch_get_main_queue(),^{
|
||||
if (!currentLocation) {
|
||||
completion(nil, locationError);
|
||||
}
|
||||
else {
|
||||
completion([self _currentPlaceGraphRequestForLocation:currentLocation bluetoothBeacons:currentBeacons minimumConfidenceLevel:minimumConfidence fields:fields], nil);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)generateCurrentPlaceRequestForCurrentLocation:(CLLocation *)currentLocation
|
||||
withMinimumConfidenceLevel:(FBSDKPlaceLocationConfidence)minimumConfidence
|
||||
fields:(nullable NSArray<NSString *> *)fields
|
||||
completion:(nonnull FBSDKCurrentPlaceGraphRequestCompletion)completion
|
||||
{
|
||||
[self.bluetoothScanner scanForBeaconsWithCompletion:^(NSArray<FBSDKBluetoothBeacon *> * _Nullable beacons) {
|
||||
completion([self _currentPlaceGraphRequestForLocation:currentLocation bluetoothBeacons:beacons minimumConfidenceLevel:minimumConfidence fields:fields], nil);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
- (FBSDKGraphRequest *)currentPlaceFeedbackRequestForPlaceID:(NSString *)placeID
|
||||
tracking:(NSString *)tracking
|
||||
wasHere:(BOOL)wasHere
|
||||
{
|
||||
return [[FBSDKGraphRequest alloc]
|
||||
initWithGraphPath:@"current_place/feedback"
|
||||
parameters:@{@"tracking" : tracking,
|
||||
@"place_id" : placeID,
|
||||
@"was_here" : @(wasHere)}
|
||||
tokenString:self._tokenString
|
||||
version:nil
|
||||
HTTPMethod:@"POST"];
|
||||
}
|
||||
|
||||
- (FBSDKGraphRequest *)placeInfoRequestForPlaceID:(NSString *)placeID
|
||||
fields:(NSArray<NSString *> *)fields
|
||||
{
|
||||
NSDictionary *parameters = @{};
|
||||
if (fields) {
|
||||
parameters = @{ParameterKeyFields : [fields componentsJoinedByString:@","]};
|
||||
}
|
||||
|
||||
return [[FBSDKGraphRequest alloc]
|
||||
initWithGraphPath:placeID
|
||||
parameters:parameters
|
||||
tokenString:self._tokenString
|
||||
version:nil
|
||||
HTTPMethod:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Helper Methods
|
||||
|
||||
- (FBSDKGraphRequest *)_currentPlaceGraphRequestForLocation:(CLLocation *)location
|
||||
bluetoothBeacons:(NSArray<FBSDKBluetoothBeacon *> *)beacons
|
||||
minimumConfidenceLevel:(FBSDKPlaceLocationConfidence)minimumConfidence
|
||||
fields:(NSArray<NSString *> *)fields
|
||||
{
|
||||
NSMutableDictionary *parameters = [NSMutableDictionary new];
|
||||
|
||||
parameters[@"coordinates"] = [self _jsonStringForObject:@{@"latitude" : @(location.coordinate.latitude),
|
||||
@"longitude" : @(location.coordinate.longitude)}];
|
||||
|
||||
parameters[@"summary"] = @"tracking";
|
||||
|
||||
NSArray *beaconParams = [self _bluetoothParametersForBeacons:beacons];
|
||||
if (beaconParams) {
|
||||
parameters[@"bluetooth"] = [self _jsonStringForObject:@{@"enabled" : @YES,
|
||||
@"scans" : beaconParams}];
|
||||
}
|
||||
|
||||
NSDictionary *networkInfo = [self _networkInfo];
|
||||
if (networkInfo) {
|
||||
NSString *ssid = networkInfo[@"SSID"];
|
||||
NSString *bssid = networkInfo[@"BSSID"];
|
||||
if ((ssid && bssid) &&
|
||||
!([ssid containsString:@"_nomap"] || [ssid containsString:@"_optout"])) {
|
||||
parameters[@"wifi"] = [self _jsonStringForObject:@{@"enabled" : @YES,
|
||||
@"current_connection" : @{@"ssid" : ssid,
|
||||
@"mac_address" : bssid}}];
|
||||
}
|
||||
}
|
||||
|
||||
if (minimumConfidence != FBSDKPlaceLocationConfidenceNotApplicable) {
|
||||
parameters[@"min_confidence_level"] = [self _confidenceWebKeyForConfidence:minimumConfidence];
|
||||
}
|
||||
|
||||
if (fields) {
|
||||
parameters[ParameterKeyFields] = [fields componentsJoinedByString:@","];
|
||||
}
|
||||
|
||||
return [[FBSDKGraphRequest alloc]
|
||||
initWithGraphPath:@"current_place/results"
|
||||
parameters:parameters
|
||||
tokenString:self._tokenString
|
||||
version:nil
|
||||
HTTPMethod:nil];
|
||||
|
||||
}
|
||||
|
||||
- (NSDictionary *)_networkInfo
|
||||
{
|
||||
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
|
||||
|
||||
for (NSString *interfaceName in interfaceNames) {
|
||||
NSDictionary *networkInfo = CFBridgingRelease(CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
|
||||
if (networkInfo.count > 0) {
|
||||
return networkInfo;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *)_bluetoothParametersForBeacons:(NSArray<FBSDKBluetoothBeacon *> *)beacons
|
||||
{
|
||||
if (!beacons) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSMutableArray *beaconDicts = [NSMutableArray new];
|
||||
for (FBSDKBluetoothBeacon *beacon in beacons) {
|
||||
|
||||
[beaconDicts addObject:@{@"payload" : beacon.payload,
|
||||
@"rssi" : beacon.RSSI}];
|
||||
}
|
||||
|
||||
return beaconDicts;
|
||||
}
|
||||
|
||||
- (NSString *)_confidenceWebKeyForConfidence:(FBSDKPlaceLocationConfidence)confidence
|
||||
{
|
||||
switch (confidence) {
|
||||
case FBSDKPlaceLocationConfidenceNotApplicable:
|
||||
return @"";
|
||||
break;
|
||||
case FBSDKPlaceLocationConfidenceLow:
|
||||
return @"low";
|
||||
break;
|
||||
case FBSDKPlaceLocationConfidenceMedium:
|
||||
return @"medium";
|
||||
break;
|
||||
case FBSDKPlaceLocationConfidenceHigh:
|
||||
return @"high";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)_jsonStringForObject:(id)object
|
||||
{
|
||||
if (![NSJSONSerialization isValidJSONObject:object]) {
|
||||
return @"";
|
||||
}
|
||||
|
||||
NSError *error;
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object options:0 error:&error];
|
||||
if (!error && jsonData) {
|
||||
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
else {
|
||||
return @"";
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)_tokenString
|
||||
{
|
||||
return [FBSDKAccessToken currentAccessToken].tokenString ?: [NSString stringWithFormat:@"%@|%@", [FBSDKSettings appID], [FBSDKSettings clientToken]];
|
||||
}
|
||||
|
||||
#pragma mark - CLLocationManager Delegate
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations
|
||||
{
|
||||
CLLocation *mostRecentLocation = locations.lastObject;
|
||||
[self _callCompletionBlocksWithLocation:mostRecentLocation error:nil];
|
||||
}
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
|
||||
{
|
||||
[self _callCompletionBlocksWithLocation:nil error:error];
|
||||
}
|
||||
|
||||
- (void)_callCompletionBlocksWithLocation:(CLLocation *)location error:(NSError *)error
|
||||
{
|
||||
for (FBSDKLocationRequestCompletion completionBlock in self.locationCompletionBlocks) {
|
||||
completionBlock(location, error);
|
||||
}
|
||||
[self.locationCompletionBlocks removeAllObjects];
|
||||
}
|
||||
|
||||
@end
|
||||
Generated
+34
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
//
|
||||
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||
// copy, modify, and distribute this software in source code or binary form for use
|
||||
// in connection with the web services and APIs provided by Facebook.
|
||||
//
|
||||
// As with any software that integrates with the Facebook platform, your use of
|
||||
// this software is subject to the Facebook Developer Principles and Policies
|
||||
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||
// included in all copies or substantial portions of the software.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface FBSDKBluetoothBeacon : NSObject
|
||||
|
||||
@property (nonatomic, strong) NSNumber *_Nonnull RSSI;
|
||||
@property (nonatomic, copy) NSString *_Nonnull payload;
|
||||
|
||||
@end
|
||||
|
||||
typedef void (^BluetoothBeaconScanCompletion)(NSArray<FBSDKBluetoothBeacon *> *_Nullable beacons);
|
||||
|
||||
@interface FBSDKPlacesBluetoothScanner : NSObject
|
||||
|
||||
- (void)scanForBeaconsWithCompletion:(nonnull BluetoothBeaconScanCompletion)completion;
|
||||
|
||||
@end
|
||||
Generated
+181
@@ -0,0 +1,181 @@
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
//
|
||||
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||
// copy, modify, and distribute this software in source code or binary form for use
|
||||
// in connection with the web services and APIs provided by Facebook.
|
||||
//
|
||||
// As with any software that integrates with the Facebook platform, your use of
|
||||
// this software is subject to the Facebook Developer Principles and Policies
|
||||
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||
// included in all copies or substantial portions of the software.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#import "FBSDKPlacesBluetoothScanner.h"
|
||||
|
||||
#import <CoreBluetooth/CoreBluetooth.h>
|
||||
|
||||
static NSString *const FBBeaconUUIDString = @"FEB8";
|
||||
static NSString *const EddystoneBeaconUUIDString = @"FEAA";
|
||||
|
||||
static NSInteger const FBBeaconPrefix = 0xff;
|
||||
static NSInteger const EddystoneBeaconPrefix = 0xfeaa16;
|
||||
|
||||
static NSTimeInterval const scanLength = 0.5;
|
||||
|
||||
@interface FBSDKPlacesBluetoothScanner () <CBCentralManagerDelegate>
|
||||
|
||||
@property (nonatomic, strong) CBCentralManager *manager;
|
||||
@property (nonatomic, strong) NSTimer *updateTimeoutTimer;
|
||||
@property (nonatomic, strong) NSMutableArray<FBSDKBluetoothBeacon *> *discoveredBeacons;
|
||||
@property (atomic, strong) NSMutableArray<BluetoothBeaconScanCompletion> *scanCompletionBlocks;
|
||||
@property (nonatomic, assign) BOOL didPerformScan;
|
||||
|
||||
@property (nonatomic, copy, readonly) NSArray<CBUUID *> *bluetoothServices;
|
||||
@property (nonatomic, strong, readonly) CBUUID *eddystoneBeaconUUID;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKPlacesBluetoothScanner
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:@{CBCentralManagerOptionShowPowerAlertKey: @NO}];
|
||||
_discoveredBeacons = [NSMutableArray new];
|
||||
_eddystoneBeaconUUID = [CBUUID UUIDWithString:EddystoneBeaconUUIDString];
|
||||
_bluetoothServices = @[[CBUUID UUIDWithString:FBBeaconUUIDString], _eddystoneBeaconUUID];
|
||||
_scanCompletionBlocks = [NSMutableArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)scanForBeaconsWithCompletion:(BluetoothBeaconScanCompletion)completion
|
||||
{
|
||||
if (self.manager.state == CBCentralManagerStatePoweredOff ||
|
||||
self.manager.state == CBCentralManagerStateUnsupported ||
|
||||
self.manager.state == CBCentralManagerStateUnauthorized) {
|
||||
|
||||
completion(nil);
|
||||
return;
|
||||
}
|
||||
|
||||
[self.scanCompletionBlocks addObject:completion];
|
||||
|
||||
if (self.manager.state == CBCentralManagerStatePoweredOn) {
|
||||
[self _startScan];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_startScan
|
||||
{
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_9_0
|
||||
if (@available(iOS 9.0, *)) {
|
||||
if (self.manager.isScanning) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[self.discoveredBeacons removeAllObjects];
|
||||
|
||||
[self.manager scanForPeripheralsWithServices:self.bluetoothServices options:@{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES }];
|
||||
self.updateTimeoutTimer = [NSTimer scheduledTimerWithTimeInterval:scanLength target:self selector:@selector(_finalizeBluetoothScan) userInfo:nil repeats:NO];
|
||||
self.didPerformScan = YES;
|
||||
}
|
||||
|
||||
- (void)_finalizeBluetoothScan
|
||||
{
|
||||
[self.manager stopScan];
|
||||
|
||||
for (BluetoothBeaconScanCompletion completion in self.scanCompletionBlocks) {
|
||||
if (self.didPerformScan) {
|
||||
completion(self.discoveredBeacons);
|
||||
}
|
||||
else {
|
||||
completion(nil);
|
||||
}
|
||||
}
|
||||
[self.scanCompletionBlocks removeAllObjects];
|
||||
self.didPerformScan = NO;
|
||||
}
|
||||
|
||||
#pragma mark - Central Manager Delegate
|
||||
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *,id> *)advertisementData RSSI:(NSNumber *)RSSI
|
||||
{
|
||||
FBSDKBluetoothBeacon *beacon = [FBSDKBluetoothBeacon new];
|
||||
beacon.RSSI = RSSI;
|
||||
|
||||
if (advertisementData[CBAdvertisementDataManufacturerDataKey]) {
|
||||
beacon.payload = [self _dataStringForFBGravityBeaconData:advertisementData[CBAdvertisementDataManufacturerDataKey]];
|
||||
}
|
||||
else if (advertisementData[CBAdvertisementDataServiceDataKey][self.eddystoneBeaconUUID]){
|
||||
beacon.payload = [self _dataStringForEddystoneBeaconData:advertisementData[CBAdvertisementDataServiceDataKey][self.eddystoneBeaconUUID]];
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
[self.discoveredBeacons addObject:beacon];
|
||||
}
|
||||
|
||||
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
|
||||
{
|
||||
if (self.scanCompletionBlocks.count > 0) {
|
||||
if (central.state == CBCentralManagerStatePoweredOn) {
|
||||
[self _startScan];
|
||||
}
|
||||
else {
|
||||
[self _finalizeBluetoothScan];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Beacon Data Helper Methods
|
||||
|
||||
- (NSString *)_dataStringForFBGravityBeaconData:(NSData *)data
|
||||
{
|
||||
NSMutableData *manufacturerPrefix = [[NSMutableData alloc] initWithBytes:&FBBeaconPrefix length:1];
|
||||
[manufacturerPrefix appendData:data];
|
||||
|
||||
NSInteger length = manufacturerPrefix.length;
|
||||
NSMutableData *finalBeaconData = [[NSMutableData alloc] initWithBytes:&length length:1];
|
||||
[finalBeaconData appendData:manufacturerPrefix];
|
||||
|
||||
return [self _hexStringForData:finalBeaconData];
|
||||
}
|
||||
|
||||
- (NSString *)_dataStringForEddystoneBeaconData:(NSData *)data
|
||||
{
|
||||
NSMutableData *manufacturerPrefix = [[NSMutableData alloc] initWithBytes:&EddystoneBeaconPrefix length:3];
|
||||
[manufacturerPrefix appendData:data];
|
||||
|
||||
NSInteger length = manufacturerPrefix.length;
|
||||
NSMutableData *finalBeaconData = [[NSMutableData alloc] initWithBytes:&length length:1];
|
||||
[finalBeaconData appendData:manufacturerPrefix];
|
||||
|
||||
return [self _hexStringForData:finalBeaconData];
|
||||
}
|
||||
|
||||
- (NSString *)_hexStringForData:(NSData *)data
|
||||
{
|
||||
NSMutableString *hexString = [NSMutableString stringWithCapacity:data.length * 2];
|
||||
const unsigned char *rawBytes = data.bytes;
|
||||
for (NSInteger i = 0; i < data.length; i++) {
|
||||
[hexString appendFormat:@"%02x", rawBytes[i]];
|
||||
}
|
||||
|
||||
return [hexString copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKBluetoothBeacon
|
||||
|
||||
@end
|
||||
Generated
+17
@@ -0,0 +1,17 @@
|
||||
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
|
||||
You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||
copy, modify, and distribute this software in source code or binary form for use
|
||||
in connection with the web services and APIs provided by Facebook.
|
||||
|
||||
As with any software that integrates with the Facebook platform, your use of
|
||||
this software is subject to the Facebook Developer Principles and Policies
|
||||
[http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||
included in all copies or substantial portions of the software.
|
||||
|
||||
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.
|
||||
Generated
+60
@@ -0,0 +1,60 @@
|
||||
# Facebook SDK for iOS
|
||||
|
||||
[](https://cocoapods.org/pods/FBSDKCoreKit)
|
||||
[](https://travis-ci.org/facebook/facebook-objc-sdk)
|
||||
|
||||
[](https://cocoapods.org/pods/FBSDKCoreKit)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
|
||||
This open-source library allows you to integrate Facebook into your iOS app.
|
||||
|
||||
Learn more about the provided samples, documentation, integrating the SDK into your app, accessing source code, and more
|
||||
at https://developers.facebook.com/docs/ios
|
||||
|
||||
NOTE: By default, the Facebook SDK for iOS is installed in ~/Documents/FacebookSDK
|
||||
|
||||
## TRY IT OUT
|
||||
|
||||
1. Download the SDK at <https://developers.facebook.com/docs/ios> or via CocoaPods by adding the 'FBSDKCoreKit',
|
||||
'FBSDKLoginKit', and 'FBSDKShareKit' pods.
|
||||
2. Test your install: build and run the project at `~/Documents/FacebookSDK/Samples/Scrumptious/Scrumptious.xcodeproj`
|
||||
3. Check-out the tutorials available online at: <https://developers.facebook.com/docs/ios/getting-started>
|
||||
4. Start coding! Visit <https://developers.facebook.com/docs/ios> for tutorials and reference documentation.
|
||||
|
||||
## FEATURES
|
||||
|
||||
- Login - <https://developers.facebook.com/docs/facebook-login>
|
||||
- Sharing - <https://developers.facebook.com/docs/sharing>
|
||||
- App Links - <https://developers.facebook.com/docs/applinks>
|
||||
- Graph API - <https://developers.facebook.com/docs/ios/graph>
|
||||
- Analytics - <https://developers.facebook.com/docs/analytics>
|
||||
|
||||
## GIVE FEEDBACK
|
||||
|
||||
Please report bugs or issues to <https://developers.facebook.com/bugs/>
|
||||
|
||||
You can also join the [Facebook Developers Group on Facebook](https://www.facebook.com/groups/fbdevelopers/) or ask
|
||||
questions on [Stack Overflow](http://facebook.stackoverflow.com)
|
||||
|
||||
## LICENSE
|
||||
|
||||
See the [LICENSE](LICENSE) file.
|
||||
|
||||
## DEVELOPER TERMS
|
||||
|
||||
- By enabling Facebook integrations, including through this SDK, you can share information with Facebook, including
|
||||
information about people’s use of your app. Facebook will use information received in accordance with our
|
||||
[Data Use Policy](https://www.facebook.com/about/privacy/), including to provide you with insights about the
|
||||
effectiveness of your ads and the use of your app. These integrations also enable us and our partners to serve ads on
|
||||
and off Facebook.
|
||||
- You may limit your sharing of information with us by updating the Insights control in the developer tool
|
||||
`https://developers.facebook.com/apps/{app_id}/settings/advanced`.
|
||||
- If you use a Facebook integration, including to share information with us, you agree and confirm that you have
|
||||
provided appropriate and sufficiently prominent notice to and obtained the appropriate consent from your users
|
||||
regarding such collection, use, and disclosure (including, at a minimum, through your privacy policy). You further
|
||||
agree that you will not share information with us about children under the age of 13.
|
||||
- You agree to comply with all applicable laws and regulations and also agree to our Terms
|
||||
<https://www.facebook.com/policies/>, including our Platform Policies <https://developers.facebook.com/policy/>.and
|
||||
Advertising Guidelines, as applicable <https://www.facebook.com/ad_guidelines.php>.
|
||||
|
||||
By using the Facebook SDK for iOS you agree to these terms.
|
||||
Reference in new issue
Block a user