commit | author | age
|
2e29a3
|
1 |
/* |
L |
2 |
* Copyright (c) Meta Platforms, Inc. and affiliates. |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* This source code is licensed under the license found in the |
|
6 |
* LICENSE file in the root directory of this source tree. |
|
7 |
*/ |
|
8 |
|
|
9 |
#if !TARGET_OS_TV |
|
10 |
|
|
11 |
#import <Foundation/Foundation.h> |
|
12 |
|
|
13 |
#import <FBSDKCoreKit/FBSDKAppLink.h> |
|
14 |
#import <FBSDKCoreKit/FBSDKAppLinkResolving.h> |
|
15 |
|
|
16 |
@protocol FBSDKSettings; |
|
17 |
|
|
18 |
NS_ASSUME_NONNULL_BEGIN |
|
19 |
|
|
20 |
/** |
|
21 |
The result of calling navigate on a FBSDKAppLinkNavigation |
|
22 |
*/ |
|
23 |
typedef NS_ENUM(NSInteger, FBSDKAppLinkNavigationType) { |
|
24 |
/** Indicates that the navigation failed and no app was opened */ |
|
25 |
FBSDKAppLinkNavigationTypeFailure, |
|
26 |
/** Indicates that the navigation succeeded by opening the URL in the browser */ |
|
27 |
FBSDKAppLinkNavigationTypeBrowser, |
|
28 |
/** Indicates that the navigation succeeded by opening the URL in an app on the device */ |
|
29 |
FBSDKAppLinkNavigationTypeApp, |
|
30 |
} NS_SWIFT_NAME(AppLinkNavigation.Type); |
|
31 |
|
|
32 |
/** |
|
33 |
Describes the callback for appLinkFromURLInBackground. |
|
34 |
@param navType the FBSDKAppLink representing the deferred App Link |
|
35 |
@param error the error during the request, if any |
|
36 |
|
|
37 |
*/ |
|
38 |
typedef void (^ FBSDKAppLinkNavigationBlock)(FBSDKAppLinkNavigationType navType, NSError *_Nullable error) |
|
39 |
NS_SWIFT_NAME(AppLinkNavigationBlock); |
|
40 |
|
|
41 |
/** |
|
42 |
Represents a pending request to navigate to an App Link. Most developers will |
|
43 |
simply use navigateToURLInBackground: to open a URL, but developers can build |
|
44 |
custom requests with additional navigation and app data attached to them by |
|
45 |
creating FBSDKAppLinkNavigations themselves. |
|
46 |
*/ |
|
47 |
NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extension") |
|
48 |
NS_SWIFT_NAME(AppLinkNavigation) |
|
49 |
@interface FBSDKAppLinkNavigation : NSObject |
|
50 |
|
|
51 |
- (instancetype)init NS_UNAVAILABLE; |
|
52 |
+ (instancetype)new NS_UNAVAILABLE; |
|
53 |
|
|
54 |
/** |
|
55 |
The default resolver to be used for App Link resolution. If the developer has not set one explicitly, |
|
56 |
a basic, built-in FBSDKWebViewAppLinkResolver will be used. |
|
57 |
*/ |
|
58 |
@property (class, nonatomic, strong) id<FBSDKAppLinkResolving> defaultResolver |
|
59 |
NS_SWIFT_NAME(default); |
|
60 |
|
|
61 |
/** |
|
62 |
The extras for the AppLinkNavigation. This will generally contain application-specific |
|
63 |
data that should be passed along with the request, such as advertiser or affiliate IDs or |
|
64 |
other such metadata relevant on this device. |
|
65 |
*/ |
|
66 |
@property (nonatomic, readonly, copy) NSDictionary<NSString *, id> *extras; |
|
67 |
|
|
68 |
/** |
|
69 |
The al_applink_data for the AppLinkNavigation. This will generally contain data common to |
|
70 |
navigation attempts such as back-links, user agents, and other information that may be used |
|
71 |
in routing and handling an App Link request. |
|
72 |
*/ |
|
73 |
@property (nonatomic, readonly, copy) NSDictionary<NSString *, id> *appLinkData; |
|
74 |
|
|
75 |
/** The AppLink to navigate to */ |
|
76 |
@property (nonatomic, readonly, strong) FBSDKAppLink *appLink; |
|
77 |
|
|
78 |
/** |
|
79 |
Return navigation type for current instance. |
|
80 |
No-side-effect version of navigate: |
|
81 |
*/ |
|
82 |
@property (nonatomic, readonly) FBSDKAppLinkNavigationType navigationType; |
|
83 |
|
|
84 |
/** Creates an AppLinkNavigation with the given link, extras, and App Link data */ |
|
85 |
// UNCRUSTIFY_FORMAT_OFF |
|
86 |
+ (instancetype)navigationWithAppLink:(FBSDKAppLink *)appLink |
|
87 |
extras:(NSDictionary<NSString *, id> *)extras |
|
88 |
appLinkData:(NSDictionary<NSString *, id> *)appLinkData |
|
89 |
NS_SWIFT_NAME(init(appLink:extras:appLinkData:)) |
|
90 |
DEPRECATED_MSG_ATTRIBUTE("`init(appLink:extras:appLinkData:)` is deprecated and will be removed in the next major release, please use `init(appLink:extras:appLinkData:settings:)` instead"); |
|
91 |
|
|
92 |
/** Creates an AppLinkNavigation with the given link, extras, and App Link data */ |
|
93 |
+ (instancetype)navigationWithAppLink:(FBSDKAppLink *)appLink |
|
94 |
extras:(NSDictionary<NSString *, id> *)extras |
|
95 |
appLinkData:(NSDictionary<NSString *, id> *)appLinkData |
|
96 |
settings:(id<FBSDKSettings>)settings |
|
97 |
NS_SWIFT_NAME(init(appLink:extras:appLinkData:settings:)); |
|
98 |
|
|
99 |
/** |
|
100 |
Creates an NSDictionary<NSString *, id> with the correct format for iOS callback URLs, |
|
101 |
to be used as 'appLinkData' argument in the call to navigationWithAppLink:extras:appLinkData: |
|
102 |
*/ |
|
103 |
+ (NSDictionary<NSString *, NSDictionary<NSString *, NSString *> *> *)callbackAppLinkDataForAppWithName:(NSString *)appName |
|
104 |
url:(NSString *)url |
|
105 |
NS_SWIFT_NAME(callbackAppLinkData(forApp:url:)); |
|
106 |
// UNCRUSTIFY_FORMAT_ON |
|
107 |
|
|
108 |
/** Performs the navigation */ |
|
109 |
- (FBSDKAppLinkNavigationType)navigate:(NSError **)error |
|
110 |
__attribute__((swift_error(nonnull_error))); |
|
111 |
|
|
112 |
/** Returns a FBSDKAppLink for the given URL */ |
|
113 |
+ (void)resolveAppLink:(NSURL *)destination handler:(FBSDKAppLinkBlock)handler; |
|
114 |
|
|
115 |
/** Returns a FBSDKAppLink for the given URL using the given App Link resolution strategy */ |
|
116 |
+ (void)resolveAppLink:(NSURL *)destination |
|
117 |
resolver:(id<FBSDKAppLinkResolving>)resolver |
|
118 |
handler:(FBSDKAppLinkBlock)handler; |
|
119 |
|
|
120 |
/** Navigates to a FBSDKAppLink and returns whether it opened in-app or in-browser */ |
|
121 |
+ (FBSDKAppLinkNavigationType)navigateToAppLink:(FBSDKAppLink *)link error:(NSError **)error |
|
122 |
__attribute__((swift_error(nonnull_error))); |
|
123 |
|
|
124 |
/** |
|
125 |
Returns a FBSDKAppLinkNavigationType based on a FBSDKAppLink. |
|
126 |
It's essentially a no-side-effect version of navigateToAppLink:error:, |
|
127 |
allowing apps to determine flow based on the link type (e.g. open an |
|
128 |
internal web view instead of going straight to the browser for regular links.) |
|
129 |
*/ |
|
130 |
+ (FBSDKAppLinkNavigationType)navigationTypeForLink:(FBSDKAppLink *)link; |
|
131 |
|
|
132 |
/** Navigates to a URL (an asynchronous action) and returns a FBSDKNavigationType */ |
|
133 |
+ (void)navigateToURL:(NSURL *)destination handler:(FBSDKAppLinkNavigationBlock)handler; |
|
134 |
|
|
135 |
/** |
|
136 |
Navigates to a URL (an asynchronous action) using the given App Link resolution |
|
137 |
strategy and returns a FBSDKNavigationType |
|
138 |
*/ |
|
139 |
+ (void)navigateToURL:(NSURL *)destination |
|
140 |
resolver:(id<FBSDKAppLinkResolving>)resolver |
|
141 |
handler:(FBSDKAppLinkNavigationBlock)handler; |
|
142 |
|
|
143 |
@end |
|
144 |
|
|
145 |
NS_ASSUME_NONNULL_END |
|
146 |
|
|
147 |
#endif |