Skip to content

Commit

Permalink
breaking(ios): Remove fcm support for ios
Browse files Browse the repository at this point in the history
  • Loading branch information
dertieran committed Jan 10, 2025
1 parent d77adc3 commit 2e27c27
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 247 deletions.
9 changes: 0 additions & 9 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,6 @@
<header-file src="src/ios/PushPluginSettings.h"/>

<framework src="PushKit.framework"/>

<podspec>
<config>
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="Firebase/Messaging" spec="$IOS_FIREBASE_MESSAGING_VERSION" />
</pods>
</podspec>
</platform>

</plugin>
64 changes: 7 additions & 57 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@

#import "PushPlugin.h"
#import "PushPluginConstants.h"
#import "PushPluginFCM.h"
#import "PushPluginSettings.h"

@interface PushPlugin ()

@property (nonatomic, strong) PushPluginFCM *pushPluginFCM;

@property (nonatomic, strong) NSDictionary *launchNotification;
@property (nonatomic, strong) NSDictionary *notificationMessage;
@property (nonatomic, strong) NSMutableDictionary *handlerObj;
Expand All @@ -52,12 +49,6 @@ @implementation PushPlugin
@synthesize callbackId;

- (void)pluginInitialize {
self.pushPluginFCM = [[PushPluginFCM alloc] initWithGoogleServicePlist];

if([self.pushPluginFCM isFCMEnabled]) {
[self.pushPluginFCM configure:self.commandDelegate];
}

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRegisterForRemoteNotificationsWithDeviceToken:)
name:PluginDidRegisterForRemoteNotificationsWithDeviceToken
Expand Down Expand Up @@ -90,61 +81,25 @@ - (void)pluginInitialize {
}

- (void)unregister:(CDVInvokedUrlCommand *)command {
NSArray* topics = [command argumentAtIndex:0];

if (topics != nil) {
[self.pushPluginFCM unsubscribeFromTopics:topics];
} else {
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
[self successWithMessage:command.callbackId withMsg:@"unregistered"];
}
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
[self successWithMessage:command.callbackId withMsg:@"unregistered"];
}

- (void)subscribe:(CDVInvokedUrlCommand *)command {
if (!self.pushPluginFCM.isFCMEnabled) {
NSLog(@"[PushPlugin] The 'subscribe' API not allowed. FCM is not enabled.");
[self successWithMessage:command.callbackId withMsg:@"The 'subscribe' API not allowed. FCM is not enabled."];
return;
}

NSString* topic = [command argumentAtIndex:0];
if (topic == nil) {
NSLog(@"[PushPlugin] There is no topic to subscribe");
[self successWithMessage:command.callbackId withMsg:@"There is no topic to subscribe"];
return;
}

[self.pushPluginFCM subscribeToTopic:topic];
[self successWithMessage:command.callbackId withMsg:[NSString stringWithFormat:@"Successfully subscribe to topic %@", topic]];
NSLog(@"[PushPlugin] The 'subscribe' API not allowed. FCM is not enabled.");
[self successWithMessage:command.callbackId withMsg:@"The 'subscribe' API not allowed. FCM is not enabled."];
}

- (void)unsubscribe:(CDVInvokedUrlCommand *)command {
if (!self.pushPluginFCM.isFCMEnabled) {
NSLog(@"[PushPlugin] The 'unsubscribe' API not allowed. FCM is not enabled.");
[self successWithMessage:command.callbackId withMsg:@"The 'unsubscribe' API not allowed. FCM is not enabled."];
return;
}

NSString* topic = [command argumentAtIndex:0];
if (topic == nil) {
NSLog(@"[PushPlugin] There is no topic to unsubscribe from.");
[self successWithMessage:command.callbackId withMsg:@"There is no topic to unsubscribe from."];
return;
}

[self.pushPluginFCM unsubscribeFromTopic:topic];
[self successWithMessage:command.callbackId withMsg:[NSString stringWithFormat:@"Successfully unsubscribe from topic %@", topic]];
NSLog(@"[PushPlugin] The 'unsubscribe' API not allowed. FCM is not enabled.");
[self successWithMessage:command.callbackId withMsg:@"The 'unsubscribe' API not allowed. FCM is not enabled."];
}

- (void)init:(CDVInvokedUrlCommand *)command {
NSMutableDictionary* options = [command.arguments objectAtIndex:0];
[[PushPluginSettings sharedInstance] updateSettingsWithOptions:[options objectForKey:@"ios"]];
PushPluginSettings *settings = [PushPluginSettings sharedInstance];

if ([self.pushPluginFCM isFCMEnabled]) {
self.pushPluginFCM.callbackId = command.callbackId;
}

self.callbackId = command.callbackId;

if ([settings voipEnabled]) {
Expand Down Expand Up @@ -212,12 +167,7 @@ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSNotification *)notif
}

NSLog(@"[PushPlugin] Successfully registered device for remote notification. (device token: %@)", deviceToken);

if ([self.pushPluginFCM isFCMEnabled]) {
[self.pushPluginFCM configureTokens:deviceToken];
} else {
[self registerWithToken:[self convertTokenToString:deviceToken]];
}
[self registerWithToken:[self convertTokenToString:deviceToken]];
}

- (NSString *)convertTokenToString:(NSData *)deviceToken {
Expand Down
25 changes: 0 additions & 25 deletions src/ios/PushPluginFCM.h

This file was deleted.

147 changes: 0 additions & 147 deletions src/ios/PushPluginFCM.m

This file was deleted.

1 change: 0 additions & 1 deletion src/ios/PushPluginSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
@property (nonatomic, readonly) BOOL forceShowEnabled;
@property (nonatomic, readonly) BOOL voipEnabled;

@property (nonatomic, readonly, strong) NSArray *fcmTopics;
@property (nonatomic, readonly, strong) NSSet<UNNotificationCategory *> *categories;

+ (instancetype)sharedInstance;
Expand Down
9 changes: 1 addition & 8 deletions src/ios/PushPluginSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ - (instancetype)initWithDefaults {
@"clearBadge" : @(NO),
@"forceShow" : @(NO),
@"voip" : @(NO),
@"fcmTopics" : @[],
@"categories" : [NSSet set]
} mutableCopy];
}
Expand All @@ -46,9 +45,7 @@ - (void)updateSettingsWithOptions:(NSDictionary *)options {
for (NSString *key in options) {
if ([self.settingsDictionary objectForKey:key]) {
// Overrides the default setting if defined and apply the correct formatting based on the key.
if ([key isEqualToString:@"fcmTopics"]) {
self.settingsDictionary[key] = [self parseArrayOption:key fromOptions:options withDefault:nil];
} else if ([key isEqualToString:@"categories"]) {
if ([key isEqualToString:@"categories"]) {
self.settingsDictionary[key] = [self parseCategoriesFromOptions:options[key]];
} else {
self.settingsDictionary[key] = @([self parseOption:key fromOptions:options withDefault:NO]);
Expand Down Expand Up @@ -168,10 +165,6 @@ - (BOOL)voipEnabled {
return [self.settingsDictionary[@"voip"] boolValue];
}

- (NSArray *)fcmTopics {
return self.settingsDictionary[@"fcmTopics"];
}

- (NSSet<UNNotificationCategory *> *)categories {
return self.settingsDictionary[@"categories"];
}
Expand Down

0 comments on commit 2e27c27

Please sign in to comment.