Skip to content

Commit

Permalink
style(ios): format method curly bracket placement
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Sep 17, 2024
1 parent a665c1e commit 407ef91
Showing 1 changed file with 22 additions and 43 deletions.
65 changes: 22 additions & 43 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ @implementation PushPlugin : CDVPlugin
@synthesize fcmSenderId;
@synthesize fcmTopics;

-(void)initRegistration;
{
- (void)initRegistration {
[[FIRMessaging messaging] tokenWithCompletion:^(NSString *token, NSError *error) {
if (error != nil) {
NSLog(@"[PushPlugin] Error getting FCM registration token: %@", error);
Expand Down Expand Up @@ -75,8 +74,7 @@ - (void)onTokenRefresh {
#endif
}

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

if (topics != nil) {
Expand All @@ -91,8 +89,7 @@ - (void)unregister:(CDVInvokedUrlCommand*)command;
}
}

- (void)subscribe:(CDVInvokedUrlCommand*)command;
{
- (void)subscribe:(CDVInvokedUrlCommand *)command {
NSString* topic = [command argumentAtIndex:0];

if (topic != nil) {
Expand All @@ -107,8 +104,7 @@ - (void)subscribe:(CDVInvokedUrlCommand*)command;
}
}

- (void)unsubscribe:(CDVInvokedUrlCommand*)command;
{
- (void)unsubscribe:(CDVInvokedUrlCommand *)command {
NSString* topic = [command argumentAtIndex:0];

if (topic != nil) {
Expand All @@ -123,8 +119,7 @@ - (void)unsubscribe:(CDVInvokedUrlCommand*)command;
}
}

- (void)init:(CDVInvokedUrlCommand*)command;
{
- (void)init:(CDVInvokedUrlCommand *)command {
NSMutableDictionary* options = [command.arguments objectAtIndex:0];
NSMutableDictionary* iosOptions = [options objectForKey:@"ios"];
id voipArg = [iosOptions objectForKey:@"voip"];
Expand Down Expand Up @@ -344,8 +339,7 @@ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
#endif
}

- (NSString *)hexadecimalStringFromData:(NSData *)data
{
- (NSString *)hexadecimalStringFromData:(NSData *)data {
NSUInteger dataLength = data.length;
if (dataLength == 0) {
return nil;
Expand All @@ -359,8 +353,7 @@ - (NSString *)hexadecimalStringFromData:(NSData *)data
return [hexString copy];
}

- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
if (self.callbackId == nil) {
NSLog(@"[PushPlugin] Unexpected call to didFailToRegisterForRemoteNotificationsWithError, ignoring: %@", error);
return;
Expand Down Expand Up @@ -442,8 +435,7 @@ - (void)notificationReceived {
}
}

- (void)clearNotification:(CDVInvokedUrlCommand *)command
{
- (void)clearNotification:(CDVInvokedUrlCommand *)command {
NSNumber *notId = [command.arguments objectAtIndex:0];
[[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> * _Nonnull notifications) {
/*
Expand All @@ -464,8 +456,7 @@ - (void)clearNotification:(CDVInvokedUrlCommand *)command
}];
}

- (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command
{
- (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
NSMutableDictionary* options = [command.arguments objectAtIndex:0];
int badge = [[options objectForKey:@"badge"] intValue] ?: 0;

Expand All @@ -476,25 +467,22 @@ - (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command
[self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
}

- (void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command
{
- (void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
NSInteger badge = [UIApplication sharedApplication].applicationIconBadgeNumber;

CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)badge];
[self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
}

- (void)clearAllNotifications:(CDVInvokedUrlCommand *)command
{
- (void)clearAllNotifications:(CDVInvokedUrlCommand *)command {
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

NSString* message = [NSString stringWithFormat:@"cleared all notifications"];
CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
[self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
}

- (void)hasPermission:(CDVInvokedUrlCommand *)command
{
- (void)hasPermission:(CDVInvokedUrlCommand *)command {
id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
if ([appDelegate respondsToSelector:@selector(checkUserHasRemoteNotificationsEnabledWithCompletionHandler:)]) {
[appDelegate performSelector:@selector(checkUserHasRemoteNotificationsEnabledWithCompletionHandler:) withObject:^(BOOL isEnabled) {
Expand All @@ -506,16 +494,15 @@ - (void)hasPermission:(CDVInvokedUrlCommand *)command
}
}

-(void)successWithMessage:(NSString *)myCallbackId withMsg:(NSString *)message
{
- (void)successWithMessage:(NSString *)myCallbackId withMsg:(NSString *)message {
if (myCallbackId != nil)
{
CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
[self.commandDelegate sendPluginResult:commandResult callbackId:myCallbackId];
}
}

-(void)registerWithToken:(NSString*)token; {
- (void)registerWithToken:(NSString *)token {
// Send result to trigger 'registration' event but keep callback
NSMutableDictionary* message = [NSMutableDictionary dictionaryWithCapacity:2];
[message setObject:token forKey:@"registrationId"];
Expand All @@ -529,16 +516,14 @@ -(void)registerWithToken:(NSString*)token; {
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
}

-(void)failWithMessage:(NSString *)myCallbackId withMsg:(NSString *)message withError:(NSError *)error
{
- (void)failWithMessage:(NSString *)myCallbackId withMsg:(NSString *)message withError:(NSError *)error {
NSString *errorMessage = (error) ? [NSString stringWithFormat:@"%@ - %@", message, [error localizedDescription]] : message;
CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMessage];

[self.commandDelegate sendPluginResult:commandResult callbackId:myCallbackId];
}

-(void) finish:(CDVInvokedUrlCommand*)command
{
- (void) finish:(CDVInvokedUrlCommand *)command {
NSLog(@"[PushPlugin] finish called");

[self.commandDelegate runInBackground:^ {
Expand All @@ -557,8 +542,7 @@ -(void) finish:(CDVInvokedUrlCommand*)command
}];
}

-(void)stopBackgroundTask:(NSTimer*)timer
{
- (void)stopBackgroundTask:(NSTimer *)timer {
UIApplication *app = [UIApplication sharedApplication];

NSLog(@"[PushPlugin] stopBackgroundTask called");
Expand All @@ -575,8 +559,7 @@ -(void)stopBackgroundTask:(NSTimer*)timer
}


- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type
{
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
if([credentials.token length] == 0) {
NSLog(@"[PushPlugin] VoIP register error - No device token:");
return;
Expand All @@ -592,20 +575,17 @@ - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPush
[self registerWithToken:sToken];
}

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type
{
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
NSLog(@"[PushPlugin] VoIP Notification received");
self.notificationMessage = payload.dictionaryPayload;
[self notificationReceived];
}

- (void)handleNotificationSettings:(NSNotification *)notification
{
- (void)handleNotificationSettings:(NSNotification *)notification {
[self handleNotificationSettingsWithAuthorizationOptions:nil];
}

- (void)handleNotificationSettingsWithAuthorizationOptions:(NSNumber *)authorizationOptionsObject
{
- (void)handleNotificationSettingsWithAuthorizationOptions:(NSNumber *)authorizationOptionsObject {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
UNAuthorizationOptions authorizationOptions = [authorizationOptionsObject unsignedIntegerValue];

Expand Down Expand Up @@ -638,8 +618,7 @@ - (void)handleNotificationSettingsWithAuthorizationOptions:(NSNumber *)authoriza
}];
}

- (void)registerForRemoteNotifications
{
- (void)registerForRemoteNotifications {
[[UIApplication sharedApplication] registerForRemoteNotifications];
}

Expand Down

0 comments on commit 407ef91

Please sign in to comment.