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