FIRDLRetrievalProcessResult.m 2.1 KB

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