Skip to content

Commit 6a81713

Browse files
authored
Update FIAM to use NS_UNAVAILABLE (#8480)
* Update fiam to use ns_unavailable * add pr number * Add missing doc comment * fix test
1 parent 26b561a commit 6a81713

File tree

4 files changed

+51
-21
lines changed

4 files changed

+51
-21
lines changed

FirebaseInAppMessaging/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2021-8 -- v8.6.0
2+
- [changed] Replaced conditionally-compiled APIs with `API_UNAVAILABLE` annotations on unsupported platforms (#8480).
3+
14
# 2021-8 -- v.8.5.0
25
- [added] Added support for unit testing with in-app message data objects (#8351).
36
- [added] Added support for prototyping custom in-app message views in SwiftUI (#8351).

FirebaseInAppMessaging/Sources/Public/FirebaseInAppMessaging/FIRInAppMessaging.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import <TargetConditionals.h>
18-
#if TARGET_OS_IOS || TARGET_OS_TV
19-
2017
#import <Foundation/Foundation.h>
2118

2219
@class FIRApp;
@@ -41,9 +38,12 @@ NS_ASSUME_NONNULL_BEGIN
4138
* Swift or YES/NO (objective-c).
4239
* 2. Set `FirebaseInAppMessagingAutomaticDataCollectionEnabled` to false in the app's plist file.
4340
* 3. Global Firebase data collection setting.
41+
*
42+
* This class is unavailable on macOS, macOS Catalyst, and watchOS.
4443
**/
4544

4645
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
46+
API_UNAVAILABLE(macos, watchos)
4747
NS_SWIFT_NAME(InAppMessaging)
4848
@interface FIRInAppMessaging : NSObject
4949
/** @fn inAppMessaging
@@ -94,5 +94,3 @@ NS_SWIFT_NAME(InAppMessaging)
9494

9595
@end
9696
NS_ASSUME_NONNULL_END
97-
98-
#endif // TARGET_OS_IOS || TARGET_OS_TV

FirebaseInAppMessaging/Sources/Public/FirebaseInAppMessaging/FIRInAppMessagingRendering.h

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import <TargetConditionals.h>
18-
#if TARGET_OS_IOS || TARGET_OS_TV
17+
#import <Foundation/Foundation.h>
1918

20-
#import <UIKit/UIKit.h>
19+
@class UIColor;
2120

2221
NS_ASSUME_NONNULL_BEGIN
2322

24-
/// The type and UI style of an in-app message.
23+
/// The type and UI style of an in-app message. This enum is unavailable on macOS, macOS Catalyst,
24+
/// and watchOS.
2525
typedef NS_ENUM(NSInteger, FIRInAppMessagingDisplayMessageType) {
2626
/// Modal style.
2727
FIRInAppMessagingDisplayMessageTypeModal,
@@ -31,18 +31,21 @@ typedef NS_ENUM(NSInteger, FIRInAppMessagingDisplayMessageType) {
3131
FIRInAppMessagingDisplayMessageTypeImageOnly,
3232
/// Card style.
3333
FIRInAppMessagingDisplayMessageTypeCard
34-
};
34+
} API_UNAVAILABLE(macos, watchos);
3535

36-
/// Represents how an in-app message should be triggered to appear.
36+
/// Represents how an in-app message should be triggered to appear. This enum is unavailable on
37+
/// macOS, macOS Catalyst, and watchOS.
3738
typedef NS_ENUM(NSInteger, FIRInAppMessagingDisplayTriggerType) {
3839
/// Triggered on app foreground.
3940
FIRInAppMessagingDisplayTriggerTypeOnAppForeground,
4041
/// Triggered from an analytics event being fired.
4142
FIRInAppMessagingDisplayTriggerTypeOnAnalyticsEvent
42-
};
43+
} API_UNAVAILABLE(macos, watchos);
4344

44-
/** Contains the display information for an action button.
45+
/** Contains the display information for an action button. This class is unavailable on macOS,
46+
* macOS Catalyst, and watchOS.
4547
*/
48+
API_UNAVAILABLE(macos, watchos)
4649
NS_SWIFT_NAME(InAppMessagingActionButton)
4750
@interface FIRInAppMessagingActionButton : NSObject
4851

@@ -73,8 +76,10 @@ NS_SWIFT_NAME(InAppMessagingActionButton)
7376
@end
7477

7578
/** Contain display data for an image for a fiam message.
79+
* This class is unavailable on macOS, macOS Catalyst, and watchOS.
7680
*/
7781
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
82+
API_UNAVAILABLE(macos, watchos)
7883
NS_SWIFT_NAME(InAppMessagingImageData)
7984
@interface FIRInAppMessagingImageData : NSObject
8085

@@ -98,8 +103,10 @@ NS_SWIFT_NAME(InAppMessagingImageData)
98103
@end
99104

100105
/** Defines the metadata for the campaign to which a FIAM message belongs.
106+
* This class is unavailable on macOS, macOS Catalyst, and watchOS.
101107
*/
102108
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
109+
API_UNAVAILABLE(macos, watchos)
103110
NS_SWIFT_NAME(InAppMessagingCampaignInfo)
104111
@interface FIRInAppMessagingCampaignInfo : NSObject
105112

@@ -124,8 +131,10 @@ NS_SWIFT_NAME(InAppMessagingCampaignInfo)
124131
@end
125132

126133
/** Defines the metadata for a FIAM action.
134+
* This class is unavailable on macOS, macOS Catalyst, and watchOS.
127135
*/
128136
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
137+
API_UNAVAILABLE(macos, watchos)
129138
NS_SWIFT_NAME(InAppMessagingAction)
130139
@interface FIRInAppMessagingAction : NSObject
131140

@@ -151,8 +160,10 @@ NS_SWIFT_NAME(InAppMessagingAction)
151160
/**
152161
* Base class representing a FIAM message to be displayed. Don't create instance
153162
* of this class directly. Instantiate one of its subclasses instead.
163+
* This class is unavailable on macOS, macOS Catalyst, and watchOS.
154164
*/
155165
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
166+
API_UNAVAILABLE(macos, watchos)
156167
NS_SWIFT_NAME(InAppMessagingDisplayMessage)
157168
@interface FIRInAppMessagingDisplayMessage : NSObject
158169

@@ -188,7 +199,12 @@ NS_SWIFT_NAME(InAppMessagingDisplayMessage)
188199

189200
@end
190201

202+
/**
203+
* A displayable in-app card message.
204+
* This class is unavailable on macOS, macOS Catalyst, and watchOS.
205+
*/
191206
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
207+
API_UNAVAILABLE(macos, watchos)
192208
NS_SWIFT_NAME(InAppMessagingCardDisplay)
193209
@interface FIRInAppMessagingCardDisplay : FIRInAppMessagingDisplayMessage
194210

@@ -262,9 +278,12 @@ NS_SWIFT_NAME(InAppMessagingCardDisplay)
262278

263279
@end
264280

265-
/** Class for defining a modal message for display.
281+
/**
282+
* Class for defining a modal message for display.
283+
* This class is unavailable on macOS, macOS Catalyst, and watchOS.
266284
*/
267285
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
286+
API_UNAVAILABLE(macos, watchos)
268287
NS_SWIFT_NAME(InAppMessagingModalDisplay)
269288
@interface FIRInAppMessagingModalDisplay : FIRInAppMessagingDisplayMessage
270289

@@ -320,9 +339,12 @@ NS_SWIFT_NAME(InAppMessagingModalDisplay)
320339

321340
@end
322341

323-
/** Class for defining a banner message for display.
342+
/**
343+
* Class for defining a banner message for display.
344+
* This class is unavailable on macOS, macOS Catalyst, and watchOS.
324345
*/
325346
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
347+
API_UNAVAILABLE(macos, watchos)
326348
NS_SWIFT_NAME(InAppMessagingBannerDisplay)
327349
@interface FIRInAppMessagingBannerDisplay : FIRInAppMessagingDisplayMessage
328350

@@ -372,9 +394,12 @@ NS_SWIFT_NAME(InAppMessagingBannerDisplay)
372394

373395
@end
374396

375-
/** Class for defining a image-only message for display.
397+
/**
398+
* Class for defining a image-only message for display.
399+
* This class is unavailable on macOS, macOS Catalyst, and watchOS.
376400
*/
377401
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
402+
API_UNAVAILABLE(macos, watchos)
378403
NS_SWIFT_NAME(InAppMessagingImageOnlyDisplay)
379404
@interface FIRInAppMessagingImageOnlyDisplay : FIRInAppMessagingDisplayMessage
380405

@@ -401,6 +426,7 @@ NS_SWIFT_NAME(InAppMessagingImageOnlyDisplay)
401426
@end
402427

403428
/// The way that an in-app message was dismissed.
429+
/// This enum is unavailable on macOS, macOS Catalyst, and watchOS.
404430
typedef NS_ENUM(NSInteger, FIRInAppMessagingDismissType) {
405431
/// Message was swiped away (only valid for banner messages).
406432
FIRInAppMessagingDismissTypeUserSwipe,
@@ -410,21 +436,24 @@ typedef NS_ENUM(NSInteger, FIRInAppMessagingDismissType) {
410436
FIRInAppMessagingDismissTypeAuto,
411437
/// Dismiss method unknown.
412438
FIRInAppMessagingDismissUnspecified,
413-
};
439+
} API_UNAVAILABLE(macos, watchos);
414440

415441
/// Error code for an in-app message that failed to display.
442+
/// This enum is unavailable on macOS, macOS Catalyst, and watchOS.
416443
typedef NS_ENUM(NSInteger, FIAMDisplayRenderErrorType) {
417444
/// The image data for this in-app message is invalid.
418445
FIAMDisplayRenderErrorTypeImageDataInvalid,
419446
/// Unexpected error.
420447
FIAMDisplayRenderErrorTypeUnspecifiedError,
421-
};
448+
} API_UNAVAILABLE(macos, watchos);
422449

423450
/**
424451
* A protocol defining those callbacks to be triggered by the message display component
425452
* under appropriate conditions.
453+
* This protocol is unavailable on macOS, macOS Catalyst, and watchOS.
426454
*/
427455
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
456+
API_UNAVAILABLE(macos, watchos)
428457
NS_SWIFT_NAME(InAppMessagingDisplayDelegate)
429458
@protocol FIRInAppMessagingDisplayDelegate <NSObject>
430459

@@ -481,8 +510,10 @@ NS_SWIFT_NAME(InAppMessagingDisplayDelegate)
481510

482511
/**
483512
* The protocol that a FIAM display component must implement.
513+
* This protocol is unavailable on macOS, macOS Catalyst, and watchOS.
484514
*/
485515
NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
516+
API_UNAVAILABLE(macos, watchos)
486517
NS_SWIFT_NAME(InAppMessagingDisplay)
487518
@protocol FIRInAppMessagingDisplay
488519

@@ -497,5 +528,3 @@ NS_SWIFT_NAME(InAppMessagingDisplay)
497528
displayDelegate:(id<FIRInAppMessagingDisplayDelegate>)displayDelegate;
498529
@end
499530
NS_ASSUME_NONNULL_END
500-
501-
#endif // TARGET_OS_IOS || TARGET_OS_TV

FirebaseInAppMessaging/Tests/Integration/DefaultUITestApp/FiamDisplaySwiftExample/CommonMessageTestVC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import Foundation
17+
import UIKit
1818

1919
class CommonMessageTestVC: UIViewController, InAppMessagingDisplayDelegate {
2020
var messageClosedWithClick = false

0 commit comments

Comments
 (0)