commit | author | age
|
bad748
|
1 |
/* |
W |
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 <Foundation/Foundation.h> |
|
12 |
|
|
13 |
#import <Bolts/BFAppLink.h> |
|
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 |
*/ |
13e53a
|
36 |
NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extension") |
bad748
|
37 |
@interface BFAppLinkNavigation : NSObject |
W |
38 |
|
|
39 |
/*! |
|
40 |
The extras for the AppLinkNavigation. This will generally contain application-specific |
|
41 |
data that should be passed along with the request, such as advertiser or affiliate IDs or |
|
42 |
other such metadata relevant on this device. |
|
43 |
*/ |
|
44 |
@property (nonatomic, copy, readonly) NSDictionary *extras; |
|
45 |
|
|
46 |
/*! |
|
47 |
The al_applink_data for the AppLinkNavigation. This will generally contain data common to |
|
48 |
navigation attempts such as back-links, user agents, and other information that may be used |
|
49 |
in routing and handling an App Link request. |
|
50 |
*/ |
|
51 |
@property (nonatomic, copy, readonly) NSDictionary *appLinkData; |
|
52 |
|
|
53 |
/*! The AppLink to navigate to */ |
|
54 |
@property (nonatomic, strong, readonly) BFAppLink *appLink; |
|
55 |
|
|
56 |
/*! Creates an AppLinkNavigation with the given link, extras, and App Link data */ |
|
57 |
+ (instancetype)navigationWithAppLink:(BFAppLink *)appLink |
|
58 |
extras:(NSDictionary *)extras |
|
59 |
appLinkData:(NSDictionary *)appLinkData; |
|
60 |
|
9febd9
|
61 |
/*! |
W |
62 |
Creates an NSDictionary with the correct format for iOS callback URLs, |
|
63 |
to be used as 'appLinkData' argument in the call to navigationWithAppLink:extras:appLinkData: |
|
64 |
*/ |
|
65 |
+ (NSDictionary *)callbackAppLinkDataForAppWithName:(NSString *)appName url:(NSString *)url; |
|
66 |
|
bad748
|
67 |
/*! Performs the navigation */ |
W |
68 |
- (BFAppLinkNavigationType)navigate:(NSError **)error; |
|
69 |
|
|
70 |
/*! Returns a BFAppLink for the given URL */ |
|
71 |
+ (BFTask *)resolveAppLinkInBackground:(NSURL *)destination; |
|
72 |
|
|
73 |
/*! Returns a BFAppLink for the given URL using the given App Link resolution strategy */ |
|
74 |
+ (BFTask *)resolveAppLinkInBackground:(NSURL *)destination resolver:(id<BFAppLinkResolving>)resolver; |
|
75 |
|
|
76 |
/*! Navigates to a BFAppLink and returns whether it opened in-app or in-browser */ |
|
77 |
+ (BFAppLinkNavigationType)navigateToAppLink:(BFAppLink *)link error:(NSError **)error; |
|
78 |
|
9febd9
|
79 |
/*! |
W |
80 |
Returns a BFAppLinkNavigationType based on a BFAppLink. |
|
81 |
It's essentially a no-side-effect version of navigateToAppLink:error:, |
|
82 |
allowing apps to determine flow based on the link type (e.g. open an |
|
83 |
internal web view instead of going straight to the browser for regular links.) |
|
84 |
*/ |
|
85 |
+ (BFAppLinkNavigationType)navigationTypeForLink:(BFAppLink *)link; |
|
86 |
|
|
87 |
/*! |
|
88 |
Return navigation type for current instance. |
|
89 |
No-side-effect version of navigate: |
|
90 |
*/ |
|
91 |
- (BFAppLinkNavigationType)navigationType; |
|
92 |
|
bad748
|
93 |
/*! Navigates to a URL (an asynchronous action) and returns a BFNavigationType */ |
W |
94 |
+ (BFTask *)navigateToURLInBackground:(NSURL *)destination; |
|
95 |
|
|
96 |
/*! |
|
97 |
Navigates to a URL (an asynchronous action) using the given App Link resolution |
|
98 |
strategy and returns a BFNavigationType |
|
99 |
*/ |
|
100 |
+ (BFTask *)navigateToURLInBackground:(NSURL *)destination resolver:(id<BFAppLinkResolving>)resolver; |
|
101 |
|
|
102 |
/*! |
|
103 |
Gets the default resolver to be used for App Link resolution. If the developer has not set one explicitly, |
|
104 |
a basic, built-in resolver will be used. |
|
105 |
*/ |
|
106 |
+ (id<BFAppLinkResolving>)defaultResolver; |
|
107 |
|
|
108 |
/*! |
|
109 |
Sets the default resolver to be used for App Link resolution. Setting this to nil will revert the |
|
110 |
default resolver to the basic, built-in resolver provided by Bolts. |
|
111 |
*/ |
|
112 |
+ (void)setDefaultResolver:(id<BFAppLinkResolving>)resolver; |
|
113 |
|
|
114 |
@end |