commit | author | age
|
13e53a
|
1 |
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
H |
2 |
// |
|
3 |
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use, |
|
4 |
// copy, modify, and distribute this software in source code or binary form for use |
|
5 |
// in connection with the web services and APIs provided by Facebook. |
|
6 |
// |
|
7 |
// As with any software that integrates with the Facebook platform, your use of |
|
8 |
// this software is subject to the Facebook Developer Principles and Policies |
|
9 |
// [http://developers.facebook.com/policy/]. This copyright notice shall be |
|
10 |
// included in all copies or substantial portions of the software. |
|
11 |
// |
|
12 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
13 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
14 |
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
15 |
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
16 |
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
17 |
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
18 |
|
|
19 |
#import <Foundation/Foundation.h> |
|
20 |
|
|
21 |
#import "FBSDKAppLink.h" |
|
22 |
#import "FBSDKAppLinkResolving.h" |
|
23 |
|
|
24 |
NS_ASSUME_NONNULL_BEGIN |
|
25 |
|
88188e
|
26 |
/** |
13e53a
|
27 |
The result of calling navigate on a FBSDKAppLinkNavigation |
H |
28 |
*/ |
|
29 |
typedef NS_ENUM(NSInteger, FBSDKAppLinkNavigationType) { |
88188e
|
30 |
/** Indicates that the navigation failed and no app was opened */ |
13e53a
|
31 |
FBSDKAppLinkNavigationTypeFailure, |
88188e
|
32 |
/** Indicates that the navigation succeeded by opening the URL in the browser */ |
13e53a
|
33 |
FBSDKAppLinkNavigationTypeBrowser, |
88188e
|
34 |
/** Indicates that the navigation succeeded by opening the URL in an app on the device */ |
13e53a
|
35 |
FBSDKAppLinkNavigationTypeApp |
e81c27
|
36 |
} NS_SWIFT_NAME(AppLinkNavigation.Type); |
13e53a
|
37 |
|
H |
38 |
/** |
|
39 |
Describes the callback for appLinkFromURLInBackground. |
|
40 |
@param navType the FBSDKAppLink representing the deferred App Link |
|
41 |
@param error the error during the request, if any |
|
42 |
|
|
43 |
*/ |
e81c27
|
44 |
typedef void (^FBSDKAppLinkNavigationBlock)(FBSDKAppLinkNavigationType navType, NSError * _Nullable error) |
H |
45 |
NS_SWIFT_NAME(AppLinkNavigationBlock); |
13e53a
|
46 |
|
88188e
|
47 |
/** |
13e53a
|
48 |
Represents a pending request to navigate to an App Link. Most developers will |
H |
49 |
simply use navigateToURLInBackground: to open a URL, but developers can build |
|
50 |
custom requests with additional navigation and app data attached to them by |
|
51 |
creating FBSDKAppLinkNavigations themselves. |
|
52 |
*/ |
|
53 |
NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extension") |
e81c27
|
54 |
NS_SWIFT_NAME(AppLinkNavigation) |
13e53a
|
55 |
@interface FBSDKAppLinkNavigation : NSObject |
e81c27
|
56 |
|
H |
57 |
- (instancetype)init NS_UNAVAILABLE; |
|
58 |
+ (instancetype)new NS_UNAVAILABLE; |
|
59 |
|
88188e
|
60 |
/** |
e81c27
|
61 |
The default resolver to be used for App Link resolution. If the developer has not set one explicitly, |
H |
62 |
a basic, built-in FBSDKWebViewAppLinkResolver will be used. |
|
63 |
*/ |
|
64 |
@property (class, nonatomic, strong) id<FBSDKAppLinkResolving> defaultResolver |
|
65 |
NS_SWIFT_NAME(default); |
13e53a
|
66 |
|
88188e
|
67 |
/** |
13e53a
|
68 |
The extras for the AppLinkNavigation. This will generally contain application-specific |
H |
69 |
data that should be passed along with the request, such as advertiser or affiliate IDs or |
|
70 |
other such metadata relevant on this device. |
|
71 |
*/ |
|
72 |
@property (nonatomic, copy, readonly) NSDictionary<NSString *, id> *extras; |
|
73 |
|
88188e
|
74 |
/** |
13e53a
|
75 |
The al_applink_data for the AppLinkNavigation. This will generally contain data common to |
H |
76 |
navigation attempts such as back-links, user agents, and other information that may be used |
|
77 |
in routing and handling an App Link request. |
|
78 |
*/ |
|
79 |
@property (nonatomic, copy, readonly) NSDictionary<NSString *, id> *appLinkData; |
|
80 |
|
88188e
|
81 |
/** The AppLink to navigate to */ |
13e53a
|
82 |
@property (nonatomic, strong, readonly) FBSDKAppLink *appLink; |
H |
83 |
|
88188e
|
84 |
/** |
13e53a
|
85 |
Return navigation type for current instance. |
H |
86 |
No-side-effect version of navigate: |
|
87 |
*/ |
|
88 |
@property (nonatomic, readonly) FBSDKAppLinkNavigationType navigationType; |
|
89 |
|
88188e
|
90 |
/** Creates an AppLinkNavigation with the given link, extras, and App Link data */ |
13e53a
|
91 |
+ (instancetype)navigationWithAppLink:(FBSDKAppLink *)appLink |
H |
92 |
extras:(NSDictionary<NSString *, id> *)extras |
e81c27
|
93 |
appLinkData:(NSDictionary<NSString *, id> *)appLinkData |
H |
94 |
NS_SWIFT_NAME(init(appLink:extras:appLinkData:)); |
13e53a
|
95 |
|
88188e
|
96 |
/** |
13e53a
|
97 |
Creates an NSDictionary with the correct format for iOS callback URLs, |
H |
98 |
to be used as 'appLinkData' argument in the call to navigationWithAppLink:extras:appLinkData: |
|
99 |
*/ |
|
100 |
+ (NSDictionary<NSString *, NSDictionary<NSString *, NSString *> *> *)callbackAppLinkDataForAppWithName:(NSString *)appName |
e81c27
|
101 |
url:(NSString *)url |
H |
102 |
NS_SWIFT_NAME(callbackAppLinkData(forApp:url:)); |
13e53a
|
103 |
|
88188e
|
104 |
/** Performs the navigation */ |
e81c27
|
105 |
- (FBSDKAppLinkNavigationType)navigate:(NSError **)error |
H |
106 |
__attribute__((swift_error(nonnull_error))); |
13e53a
|
107 |
|
88188e
|
108 |
/** Returns a FBSDKAppLink for the given URL */ |
e81c27
|
109 |
+ (void)resolveAppLink:(NSURL *)destination handler:(FBSDKAppLinkBlock)handler; |
13e53a
|
110 |
|
88188e
|
111 |
/** Returns a FBSDKAppLink for the given URL using the given App Link resolution strategy */ |
13e53a
|
112 |
+ (void)resolveAppLink:(NSURL *)destination |
H |
113 |
resolver:(id<FBSDKAppLinkResolving>)resolver |
e81c27
|
114 |
handler:(FBSDKAppLinkBlock)handler; |
13e53a
|
115 |
|
88188e
|
116 |
/** Navigates to a FBSDKAppLink and returns whether it opened in-app or in-browser */ |
e81c27
|
117 |
+ (FBSDKAppLinkNavigationType)navigateToAppLink:(FBSDKAppLink *)link error:(NSError **)error |
H |
118 |
__attribute__((swift_error(nonnull_error))); |
13e53a
|
119 |
|
88188e
|
120 |
/** |
13e53a
|
121 |
Returns a FBSDKAppLinkNavigationType based on a FBSDKAppLink. |
H |
122 |
It's essentially a no-side-effect version of navigateToAppLink:error:, |
|
123 |
allowing apps to determine flow based on the link type (e.g. open an |
|
124 |
internal web view instead of going straight to the browser for regular links.) |
|
125 |
*/ |
|
126 |
+ (FBSDKAppLinkNavigationType)navigationTypeForLink:(FBSDKAppLink *)link; |
|
127 |
|
88188e
|
128 |
/** Navigates to a URL (an asynchronous action) and returns a FBSDKNavigationType */ |
e81c27
|
129 |
+ (void)navigateToURL:(NSURL *)destination handler:(FBSDKAppLinkNavigationBlock)handler; |
13e53a
|
130 |
|
88188e
|
131 |
/** |
13e53a
|
132 |
Navigates to a URL (an asynchronous action) using the given App Link resolution |
H |
133 |
strategy and returns a FBSDKNavigationType |
|
134 |
*/ |
|
135 |
+ (void)navigateToURL:(NSURL *)destination |
|
136 |
resolver:(id<FBSDKAppLinkResolving>)resolver |
e81c27
|
137 |
handler:(FBSDKAppLinkNavigationBlock)handler; |
13e53a
|
138 |
|
H |
139 |
@end |
|
140 |
|
|
141 |
NS_ASSUME_NONNULL_END |