diff --git a/FirebaseMessaging/Sources/FIRMessaging+ExtensionHelper.m b/FirebaseMessaging/Sources/FIRMessaging+ExtensionHelper.m new file mode 100644 index 00000000000..1902d067062 --- /dev/null +++ b/FirebaseMessaging/Sources/FIRMessaging+ExtensionHelper.m @@ -0,0 +1,37 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessaging+ExtensionHelper.h" + +#import "FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessaging.h" +#import "FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessagingExtensionHelper.h" + +@implementation FIRMessaging (ExtensionHelper) + ++ (FIRMessagingExtensionHelper *)extensionHelper { + static dispatch_once_t once; + static FIRMessagingExtensionHelper *extensionHelper; + dispatch_once(&once, ^{ + extensionHelper = [[FIRMessagingExtensionHelper alloc] init]; + }); + return extensionHelper; +} + +/// Stub used to force the linker to include the categories in this file. +void FIRInclude_FIRMessaging_ExtensionHelper_Category(void) { +} + +@end diff --git a/FirebaseMessaging/Sources/FIRMessaging.m b/FirebaseMessaging/Sources/FIRMessaging.m index af18ea77fea..590fabd042c 100644 --- a/FirebaseMessaging/Sources/FIRMessaging.m +++ b/FirebaseMessaging/Sources/FIRMessaging.m @@ -40,7 +40,6 @@ #import "FirebaseMessaging/Sources/FIRMessagingUtilities.h" #import "FirebaseMessaging/Sources/FIRMessaging_Private.h" #import "FirebaseMessaging/Sources/NSError+FIRMessaging.h" -#import "FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessagingExtensionHelper.h" #import "FirebaseMessaging/Sources/Token/FIRMessagingAuthService.h" #import "FirebaseMessaging/Sources/Token/FIRMessagingTokenInfo.h" #import "FirebaseMessaging/Sources/Token/FIRMessagingTokenManager.h" @@ -131,14 +130,6 @@ + (FIRMessaging *)messaging { return (FIRMessaging *)instance; } -+ (FIRMessagingExtensionHelper *)extensionHelper { - static dispatch_once_t once; - static FIRMessagingExtensionHelper *extensionHelper; - dispatch_once(&once, ^{ - extensionHelper = [[FIRMessagingExtensionHelper alloc] init]; - }); - return extensionHelper; -} - (instancetype)initWithAnalytics:(nullable id)analytics userDefaults:(GULUserDefaults *)defaults heartbeatLogger:(FIRHeartbeatLogger *)heartbeatLogger { @@ -1030,6 +1021,7 @@ + (NSString *)FIRMessagingSDKCurrentLocale { #pragma mark - Force Category Linking +extern void FIRInclude_FIRMessaging_ExtensionHelper_Category(void); extern void FIRInclude_NSDictionary_FIRMessaging_Category(void); extern void FIRInclude_NSError_FIRMessaging_Category(void); @@ -1038,8 +1030,8 @@ + (NSString *)FIRMessagingSDKCurrentLocale { /// This method forces the linker to include categories even if /// users do not include the '-ObjC' linker flag in their project. + (void)noop { + FIRInclude_FIRMessaging_ExtensionHelper_Category(); FIRInclude_NSDictionary_FIRMessaging_Category(); FIRInclude_NSError_FIRMessaging_Category(); } - @end diff --git a/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessaging+ExtensionHelper.h b/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessaging+ExtensionHelper.h new file mode 100644 index 00000000000..7f0fe7c7688 --- /dev/null +++ b/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessaging+ExtensionHelper.h @@ -0,0 +1,39 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#import "FIRMessaging.h" + +NS_ASSUME_NONNULL_BEGIN + +@class FIRMessagingExtensionHelper; + +@interface FIRMessaging (ExtensionHelper) + +/** + * Use the MessagingExtensionHelper to populate rich UI content for your notifications. + * For example, if an image URL is set in your notification payload or on the console, + * you can use the MessagingExtensionHelper instance returned from this method to render + * the image in your notification. + * + * @return An instance of MessagingExtensionHelper that handles the extensions API. + */ ++ (FIRMessagingExtensionHelper *)extensionHelper NS_SWIFT_NAME(serviceExtension()); + +@end + +NS_ASSUME_NONNULL_END diff --git a/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessaging.h b/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessaging.h index 4f5209bb935..f8282d30b30 100644 --- a/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessaging.h +++ b/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessaging.h @@ -136,7 +136,6 @@ NS_SWIFT_NAME(MessagingMessageInfo) @end @class FIRMessaging; -@class FIRMessagingExtensionHelper; /** * A protocol to handle token update or data message delivery from FCM. @@ -184,17 +183,6 @@ NS_SWIFT_NAME(Messaging) */ + (instancetype)messaging NS_SWIFT_NAME(messaging()); -/** - * Use the MessagingExtensionHelper to populate rich UI content for your notifications. - * For example, if an image URL is set in your notification payload or on the console, - * you can use the MessagingExtensionHelper instance returned from this method to render - * the image in your notification. - * - * @return An instance of MessagingExtensionHelper that handles the extensions API. - */ -+ (FIRMessagingExtensionHelper *)extensionHelper NS_SWIFT_NAME(serviceExtension()) - NS_AVAILABLE(10.14, 10.0); - /** * Unavailable. Use +messaging instead. */ diff --git a/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessagingExtensionHelper.h b/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessagingExtensionHelper.h index c383d55da3f..eb25919ced3 100644 --- a/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessagingExtensionHelper.h +++ b/FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessagingExtensionHelper.h @@ -16,6 +16,8 @@ #import +#import "FIRMessaging+ExtensionHelper.h" + @class UNMutableNotificationContent, UNNotificationContent; #if __has_include() diff --git a/FirebaseMessaging/Sources/Public/FirebaseMessaging/FirebaseMessaging.h b/FirebaseMessaging/Sources/Public/FirebaseMessaging/FirebaseMessaging.h old mode 100755 new mode 100644 index c5d0bd05046..d285c078c7a --- a/FirebaseMessaging/Sources/Public/FirebaseMessaging/FirebaseMessaging.h +++ b/FirebaseMessaging/Sources/Public/FirebaseMessaging/FirebaseMessaging.h @@ -14,5 +14,6 @@ * limitations under the License. */ +#import "FIRMessaging+ExtensionHelper.h" #import "FIRMessaging.h" #import "FIRMessagingExtensionHelper.h"