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 |
*/ |
|
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 |
|
9febd9
|
60 |
/*! |
W |
61 |
Creates an NSDictionary with the correct format for iOS callback URLs, |
|
62 |
to be used as 'appLinkData' argument in the call to navigationWithAppLink:extras:appLinkData: |
|
63 |
*/ |
|
64 |
+ (NSDictionary *)callbackAppLinkDataForAppWithName:(NSString *)appName url:(NSString *)url; |
|
65 |
|
bad748
|
66 |
/*! Performs the navigation */ |
W |
67 |
- (BFAppLinkNavigationType)navigate:(NSError **)error; |
|
68 |
|
|
69 |
/*! Returns a BFAppLink for the given URL */ |
|
70 |
+ (BFTask *)resolveAppLinkInBackground:(NSURL *)destination; |
|
71 |
|
|
72 |
/*! Returns a BFAppLink for the given URL using the given App Link resolution strategy */ |
|
73 |
+ (BFTask *)resolveAppLinkInBackground:(NSURL *)destination resolver:(id<BFAppLinkResolving>)resolver; |
|
74 |
|
|
75 |
/*! Navigates to a BFAppLink and returns whether it opened in-app or in-browser */ |
|
76 |
+ (BFAppLinkNavigationType)navigateToAppLink:(BFAppLink *)link error:(NSError **)error; |
|
77 |
|
9febd9
|
78 |
/*! |
W |
79 |
Returns a BFAppLinkNavigationType based on a BFAppLink. |
|
80 |
It's essentially a no-side-effect version of navigateToAppLink:error:, |
|
81 |
allowing apps to determine flow based on the link type (e.g. open an |
|
82 |
internal web view instead of going straight to the browser for regular links.) |
|
83 |
*/ |
|
84 |
+ (BFAppLinkNavigationType)navigationTypeForLink:(BFAppLink *)link; |
|
85 |
|
|
86 |
/*! |
|
87 |
Return navigation type for current instance. |
|
88 |
No-side-effect version of navigate: |
|
89 |
*/ |
|
90 |
- (BFAppLinkNavigationType)navigationType; |
|
91 |
|
bad748
|
92 |
/*! Navigates to a URL (an asynchronous action) and returns a BFNavigationType */ |
W |
93 |
+ (BFTask *)navigateToURLInBackground:(NSURL *)destination; |
|
94 |
|
|
95 |
/*! |
|
96 |
Navigates to a URL (an asynchronous action) using the given App Link resolution |
|
97 |
strategy and returns a BFNavigationType |
|
98 |
*/ |
|
99 |
+ (BFTask *)navigateToURLInBackground:(NSURL *)destination resolver:(id<BFAppLinkResolving>)resolver; |
|
100 |
|
|
101 |
/*! |
|
102 |
Gets the default resolver to be used for App Link resolution. If the developer has not set one explicitly, |
|
103 |
a basic, built-in resolver will be used. |
|
104 |
*/ |
|
105 |
+ (id<BFAppLinkResolving>)defaultResolver; |
|
106 |
|
|
107 |
/*! |
|
108 |
Sets the default resolver to be used for App Link resolution. Setting this to nil will revert the |
|
109 |
default resolver to the basic, built-in resolver provided by Bolts. |
|
110 |
*/ |
|
111 |
+ (void)setDefaultResolver:(id<BFAppLinkResolving>)resolver; |
|
112 |
|
|
113 |
@end |