FIRSegmentation.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2019 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. NS_ASSUME_NONNULL_BEGIN
  18. @class FIRApp;
  19. /**
  20. * The Firebase Segmentation SDK is used to associate a custom, non-Firebase installation
  21. * identifier to Firebase. Once this custom installation identifier is set, developers can use the
  22. * current app installation for segmentation purposes. If the custom installation identifier is
  23. * explicitely set to nil, any existing custom installation identifier data will be removed.
  24. */
  25. NS_SWIFT_NAME(Segmentation)
  26. @interface FIRSegmentation : NSObject
  27. /// Firebase Segmentation service fetch error.
  28. typedef NS_ENUM(NSInteger, FIRSegmentationErrorCode) {
  29. /// No error. The operation was successful.
  30. FIRSegmentationErrorCodeNone = 8001,
  31. /// An internal error occurred.
  32. FIRSegmentationErrorCodeInternal = 8002,
  33. /// Error indicating that backend reports an existing association for this custom installation
  34. /// identifier.
  35. FIRSegmentationErrorCodeConflict = 8003,
  36. /// Error indicating that a network error occurred during association.
  37. FIRSegmentationErrorCodeNetwork = 8004,
  38. } NS_SWIFT_NAME(SegmentationErrorCode);
  39. /**
  40. * Singleton instance (scoped to the default FIRApp)
  41. * Returns the FIRSegmentation instance for the default Firebase application. Please make sure you
  42. * call [FIRApp configure] beforehand for a default Firebase app to already be initialized and
  43. * available. This singleton class instance lets you set your own custom identifier to be used for
  44. * user segmentation purposes within Firebase.
  45. *
  46. * @return A shared instance of FIRSegmentation.
  47. */
  48. + (instancetype)segmentation;
  49. /// Singleton instance (scoped to FIRApp)
  50. /// Returns the FIRSegmentation instance for your Firebase application. This singleton class
  51. /// instance lets you set your own custom identifier to be used for targeting purposes within
  52. /// Firebase.
  53. + (instancetype)segmentationWithApp:(FIRApp *)app;
  54. /**
  55. * :nodoc:
  56. * Unavailable. Use +segmentation instead.
  57. */
  58. - (instancetype)init __attribute__((unavailable("Use +segmentation instead.")));
  59. /// Set your own custom installation ID to be used for segmentation purposes.
  60. /// This method needs to be called every time (and immediately) upon any changes to the custom
  61. /// installation ID.
  62. /// @param completionHandler Set custom installation ID completion. Returns nil if initialization
  63. /// succeeded or an NSError object if initialization failed.
  64. - (void)setCustomInstallationID:(nullable NSString *)customInstallationID
  65. completion:(nullable void (^)(NSError *))completionHandler;
  66. @end
  67. NS_ASSUME_NONNULL_END