You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FIRUtilities.m 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2017 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 "FIRUtilities.h"
  17. // Plist file name.
  18. NSString *const kGoogleServiceInfoFileName = @"GoogleService-Info";
  19. // Plist file type.
  20. NSString *const kGoogleServiceInfoFileType = @"plist";
  21. NSString *const kGoogleAppIDPlistKey = @"GOOGLE_APP_ID";
  22. @implementation FIRUtilities
  23. + (BOOL)appContainsRealServiceInfoPlist {
  24. static BOOL containsRealServiceInfoPlist = NO;
  25. static dispatch_once_t onceToken;
  26. dispatch_once(&onceToken, ^{
  27. NSBundle *bundle = [NSBundle mainBundle];
  28. containsRealServiceInfoPlist = [self containsRealServiceInfoPlistInBundle:bundle];
  29. });
  30. return containsRealServiceInfoPlist;
  31. }
  32. + (BOOL)containsRealServiceInfoPlistInBundle:(NSBundle *)bundle {
  33. NSString *bundlePath = bundle.bundlePath;
  34. if (!bundlePath.length) {
  35. return NO;
  36. }
  37. NSString *plistFilePath = [bundle pathForResource:kGoogleServiceInfoFileName
  38. ofType:kGoogleServiceInfoFileType];
  39. if (!plistFilePath.length) {
  40. return NO;
  41. }
  42. NSDictionary *plist = [NSDictionary dictionaryWithContentsOfFile:plistFilePath];
  43. if (!plist) {
  44. return NO;
  45. }
  46. // Perform a very naive validation by checking to see if the plist has the dummy google app id
  47. NSString *googleAppID = plist[kGoogleAppIDPlistKey];
  48. if (!googleAppID.length) {
  49. return NO;
  50. }
  51. return YES;
  52. }
  53. + (NSURL *)extractURL: (FIRDynamicLink*)dynamicLink {
  54. NSURL *url = nil;
  55. if (dynamicLink != nil) {
  56. NSURL *dynamicLinkURL = dynamicLink.url;
  57. if (dynamicLinkURL != nil
  58. && (dynamicLink.matchType == FIRDLMatchTypeUnique
  59. || dynamicLink.matchType == FIRDLMatchTypeDefault)) {
  60. // Strong match, process it.
  61. url = dynamicLinkURL;
  62. }
  63. }
  64. return url;
  65. }
  66. @end