FIRDLRetrievalProcessResult.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 <TargetConditionals.h>
  17. #if TARGET_OS_IOS
  18. #import "FirebaseDynamicLinks/Sources/FIRDLRetrievalProcessResult.h"
  19. #import "FirebaseDynamicLinks/Sources/FIRDLRetrievalProcessResult+Private.h"
  20. #import "FirebaseDynamicLinks/Sources/FIRDynamicLink+Private.h"
  21. #import "FirebaseDynamicLinks/Sources/Utilities/FDLUtilities.h"
  22. NS_ASSUME_NONNULL_BEGIN
  23. @implementation FIRDLRetrievalProcessResult
  24. - (instancetype)initWithDynamicLink:(nullable FIRDynamicLink *)dynamicLink
  25. error:(nullable NSError *)error
  26. message:(nullable NSString *)message
  27. matchSource:(nullable NSString *)matchSource {
  28. if (self = [super init]) {
  29. _dynamicLink = dynamicLink;
  30. _error = error;
  31. _message = [message copy];
  32. _matchSource = [matchSource copy];
  33. }
  34. return self;
  35. }
  36. - (NSURL *)URLWithCustomURLScheme:(NSString *)customURLScheme {
  37. NSURL *URL;
  38. if (_dynamicLink) {
  39. NSString *queryString = FIRDLURLQueryStringFromDictionary(_dynamicLink.parametersDictionary);
  40. NSMutableString *URLString = [[NSMutableString alloc] init];
  41. [URLString appendString:customURLScheme];
  42. [URLString appendString:@"://google/link/"];
  43. [URLString appendString:queryString];
  44. URL = [NSURL URLWithString:URLString];
  45. } else {
  46. NSMutableString *URLString = [[NSMutableString alloc] init];
  47. [URLString appendString:customURLScheme];
  48. [URLString appendString:@"://google/link/?dismiss=1&is_weak_match=1"];
  49. URL = [NSURL URLWithString:URLString];
  50. }
  51. return URL;
  52. }
  53. @end
  54. NS_ASSUME_NONNULL_END
  55. #endif // TARGET_OS_IOS