FIRDynamicLinkNetworking.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright 2018 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "FirebaseDynamicLinks/Sources/Public/FirebaseDynamicLinks/FIRDynamicLinksCommon.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. /** A definition for a block used by methods that are asynchronous and may produce errors. */
  20. typedef void (^FIRDynamicLinkNetworkingErrorHandler)(NSError *_Nullable error);
  21. /** A definition for a block used to return a pending Dynamic Link. */
  22. typedef void (^FIRPostInstallAttributionCompletionHandler)(
  23. NSDictionary *_Nullable dynamicLinkParameters,
  24. NSString *_Nullable matchMessage,
  25. NSError *_Nullable error);
  26. /** A definition for a block used to return data and errors after an asynchronous task. */
  27. typedef void (^FIRNetworkRequestCompletionHandler)(NSData *_Nullable data,
  28. NSURLResponse *_Nullable response,
  29. NSError *_Nullable error);
  30. // these enums must be in sync with google/firebase/dynamiclinks/v1/dynamic_links.proto
  31. typedef NS_ENUM(NSInteger, FIRDynamicLinkNetworkingUniqueMatchVisualStyle) {
  32. // Unknown style.
  33. FIRDynamicLinkNetworkingUniqueMatchVisualStyleUnknown = 0,
  34. // Default style.
  35. FIRDynamicLinkNetworkingUniqueMatchVisualStyleDefault = 1,
  36. // Custom style.
  37. FIRDynamicLinkNetworkingUniqueMatchVisualStyleCustom = 2,
  38. };
  39. typedef NS_ENUM(NSInteger, FIRDynamicLinkNetworkingRetrievalProcessType) {
  40. // Unknown method.
  41. FIRDynamicLinkNetworkingRetrievalProcessTypeUnknown = 0,
  42. // iSDK performs a server lookup using default match in the background
  43. // when app is first-opened; no API called by developer.
  44. FIRDynamicLinkNetworkingRetrievalProcessTypeImplicitDefault = 1,
  45. // iSDK performs a server lookup by device fingerprint upon a dev API call.
  46. FIRDynamicLinkNetworkingRetrievalProcessTypeExplicitDefault = 2,
  47. // iSDK performs a unique match only if default match is found upon a dev
  48. // API call.
  49. FIRDynamicLinkNetworkingRetrievalProcessTypeOptionalUnique = 3,
  50. };
  51. /**
  52. * @fn FIRMakeHTTPRequest
  53. * @abstract A basic and simple network request method.
  54. * @param request The NSURLRequest with which to perform the network request.
  55. * @param completion The handler executed after the request has completed.
  56. */
  57. void FIRMakeHTTPRequest(NSURLRequest *request, FIRNetworkRequestCompletionHandler completion);
  58. /** The base of the FDL API URL */
  59. FOUNDATION_EXPORT NSString *const kApiaryRestBaseUrl;
  60. /**
  61. * @class FIRDynamicLinkNetworking
  62. * @abstract The class used to handle all network communications for the service.
  63. */
  64. @interface FIRDynamicLinkNetworking : NSObject
  65. /**
  66. * @method initWithAPIKey:URLScheme:
  67. * @param URLScheme Custom URL scheme of the app.
  68. * @param APIKey API Key value.
  69. */
  70. - (instancetype)initWithAPIKey:(NSString *)APIKey
  71. URLScheme:(NSString *)URLScheme NS_DESIGNATED_INITIALIZER;
  72. - (instancetype)init NS_UNAVAILABLE;
  73. /**
  74. * @method resolveShortLink:URLScheme:APIKey:completion:
  75. * @abstract Retrieves the details of the durable link that the shortened URL represents
  76. * @param url A Short Dynamic Link.
  77. * @param completion Block to be run upon completion.
  78. */
  79. - (void)resolveShortLink:(NSURL *)url
  80. FDLSDKVersion:(NSString *)FDLSDKVersion
  81. completion:(FIRDynamicLinkResolverHandler)completion;
  82. /**
  83. * @method
  84. * retrievePendingDynamicLinkWithIOSVersion:resolutionHeight:resolutionWidth:locale:localeRaw:timezone:modelName:FDLSDKVersion:appInstallationDate:uniqueMatchVisualStyle:retrievalProcessType:handler:
  85. * @abstract Retrieves a pending link from the server using the supplied device info and returns it
  86. * by executing the completion handler.
  87. */
  88. - (void)retrievePendingDynamicLinkWithIOSVersion:(NSString *)IOSVersion
  89. resolutionHeight:(NSInteger)resolutionHeight
  90. resolutionWidth:(NSInteger)resolutionWidth
  91. locale:(NSString *)locale
  92. localeRaw:(NSString *)localeRaw
  93. localeFromWebView:(NSString *)localeFromWebView
  94. timezone:(NSString *)timezone
  95. modelName:(NSString *)modelName
  96. FDLSDKVersion:(NSString *)FDLSDKVersion
  97. appInstallationDate:(NSDate *_Nullable)appInstallationDate
  98. uniqueMatchVisualStyle:
  99. (FIRDynamicLinkNetworkingUniqueMatchVisualStyle)uniqueMatchVisualStyle
  100. retrievalProcessType:
  101. (FIRDynamicLinkNetworkingRetrievalProcessType)retrievalProcessType
  102. uniqueMatchLinkToCheck:(NSURL *)uniqueMatchLinkToCheck
  103. handler:
  104. (FIRPostInstallAttributionCompletionHandler)handler;
  105. /**
  106. * @method convertInvitation:handler:
  107. * @abstract Marks an invitation as converted. You should call this method in your application after
  108. * the user performs an action that represents a successful conversion.
  109. * @param invitationID The invitation ID of the link.
  110. * @param handler A block that is called upon completion. If successful, the error parameter will be
  111. * nil. This is always executed on the main thread.
  112. */
  113. - (void)convertInvitation:(NSString *)invitationID
  114. handler:(nullable FIRDynamicLinkNetworkingErrorHandler)handler;
  115. @end
  116. NS_ASSUME_NONNULL_END