FIRDynamicLinkNetworking.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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/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. NSError *_Nullable error);
  29. // these enums must be in sync with google/firebase/dynamiclinks/v1/dynamic_links.proto
  30. typedef NS_ENUM(NSInteger, FIRDynamicLinkNetworkingUniqueMatchVisualStyle) {
  31. // Unknown style.
  32. FIRDynamicLinkNetworkingUniqueMatchVisualStyleUnknown = 0,
  33. // Default style.
  34. FIRDynamicLinkNetworkingUniqueMatchVisualStyleDefault = 1,
  35. // Custom style.
  36. FIRDynamicLinkNetworkingUniqueMatchVisualStyleCustom = 2,
  37. };
  38. typedef NS_ENUM(NSInteger, FIRDynamicLinkNetworkingRetrievalProcessType) {
  39. // Unknown method.
  40. FIRDynamicLinkNetworkingRetrievalProcessTypeUnknown = 0,
  41. // iSDK performs a server lookup using default match in the background
  42. // when app is first-opened; no API called by developer.
  43. FIRDynamicLinkNetworkingRetrievalProcessTypeImplicitDefault = 1,
  44. // iSDK performs a server lookup by device fingerprint upon a dev API call.
  45. FIRDynamicLinkNetworkingRetrievalProcessTypeExplicitDefault = 2,
  46. // iSDK performs a unique match only if default match is found upon a dev
  47. // API call.
  48. FIRDynamicLinkNetworkingRetrievalProcessTypeOptionalUnique = 3,
  49. };
  50. /**
  51. * @fn FIRMakeHTTPRequest
  52. * @abstract A basic and simple network request method.
  53. * @param request The NSURLRequest with which to perform the network request.
  54. * @param completion The handler executed after the request has completed.
  55. */
  56. void FIRMakeHTTPRequest(NSURLRequest *request, FIRNetworkRequestCompletionHandler completion);
  57. /** The base of the FDL API URL */
  58. FOUNDATION_EXPORT NSString *const kApiaryRestBaseUrl;
  59. /**
  60. * @class FIRDynamicLinkNetworking
  61. * @abstract The class used to handle all network communications for the the service.
  62. */
  63. @interface FIRDynamicLinkNetworking : NSObject
  64. /**
  65. * @method initWithAPIKey:clientID:URLScheme:
  66. * @param clientID Client ID value.
  67. * @param URLScheme Custom URL scheme of the app.
  68. * @param APIKey API Key value.
  69. */
  70. - (instancetype)initWithAPIKey:(NSString *)APIKey
  71. clientID:(NSString *)clientID
  72. URLScheme:(NSString *)URLScheme NS_DESIGNATED_INITIALIZER;
  73. - (instancetype)init NS_UNAVAILABLE;
  74. /**
  75. * @method resolveShortLink:URLScheme:APIKey:completion:
  76. * @abstract Retrieves the details of the durable link that the shortened URL represents
  77. * @param url A Short Dynamic Link.
  78. * @param completion Block to be run upon completion.
  79. */
  80. - (void)resolveShortLink:(NSURL *)url
  81. FDLSDKVersion:(NSString *)FDLSDKVersion
  82. completion:(FIRDynamicLinkResolverHandler)completion;
  83. /**
  84. * @method
  85. * retrievePendingDynamicLinkWithIOSVersion:resolutionHeight:resolutionWidth:locale:localeRaw:timezone:modelName:FDLSDKVersion:appInstallationDate:uniqueMatchVisualStyle:retrievalProcessType:handler:
  86. * @abstract Retrieves a pending link from the server using the supplied device info and returns it
  87. * by executing the completion handler.
  88. */
  89. - (void)retrievePendingDynamicLinkWithIOSVersion:(NSString *)IOSVersion
  90. resolutionHeight:(NSInteger)resolutionHeight
  91. resolutionWidth:(NSInteger)resolutionWidth
  92. locale:(NSString *)locale
  93. localeRaw:(NSString *)localeRaw
  94. localeFromWebView:(NSString *)localeFromWebView
  95. timezone:(NSString *)timezone
  96. modelName:(NSString *)modelName
  97. FDLSDKVersion:(NSString *)FDLSDKVersion
  98. appInstallationDate:(NSDate *_Nullable)appInstallationDate
  99. uniqueMatchVisualStyle:
  100. (FIRDynamicLinkNetworkingUniqueMatchVisualStyle)uniqueMatchVisualStyle
  101. retrievalProcessType:
  102. (FIRDynamicLinkNetworkingRetrievalProcessType)retrievalProcessType
  103. uniqueMatchLinkToCheck:(NSURL *)uniqueMatchLinkToCheck
  104. handler:
  105. (FIRPostInstallAttributionCompletionHandler)handler;
  106. /**
  107. * @method convertInvitation:handler:
  108. * @abstract Marks an invitation as converted. You should call this method in your application after
  109. * the user performs an action that represents a successful conversion.
  110. * @param invitationID The invitation ID of the link.
  111. * @param handler A block that is called upon completion. If successful, the error parameter will be
  112. * nil. This is always executed on the main thread.
  113. */
  114. - (void)convertInvitation:(NSString *)invitationID
  115. handler:(nullable FIRDynamicLinkNetworkingErrorHandler)handler;
  116. @end
  117. NS_ASSUME_NONNULL_END