Skip to content

Commit

Permalink
feat!(ios): update Firebase Messaging to ~> 8.1.1 (#152)
Browse files Browse the repository at this point in the history
* feat(ios): update IOS_FIREBASE_MESSAGING_VERSION to > 8
* chore(ios): removed unused methods & commented out code
* fix(ios): use new notification name FIRMessagingRegistrationTokenRefreshedNotification

Co-authored-by: Adri Van Houdt <adri.van.houdt@gmail.com>
  • Loading branch information
erisu and AdriVanHoudt committed Apr 11, 2022
1 parent 89a8c21 commit 10eee49
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 37 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</platform>

<platform name="ios">
<preference name="IOS_FIREBASE_MESSAGING_VERSION" default="~> 6.32.2"/>
<preference name="IOS_FIREBASE_MESSAGING_VERSION" default="~> 8.1.1"/>

<config-file target="config.xml" parent="/*">
<feature name="PushNotification">
Expand Down
1 change: 0 additions & 1 deletion src/ios/PushPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@

- (void)willSendDataMessageWithID:(NSString *)messageID error:(NSError *)error;
- (void)didSendDataMessageWithID:(NSString *)messageID;
- (void)didDeleteMessagesOnServer;

// VoIP Features
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type;
Expand Down
44 changes: 9 additions & 35 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

@import Firebase;
@import FirebaseCore;
@import FirebaseInstanceID;
// @import FirebaseInstanceID;
@import FirebaseMessaging;

@implementation PushPlugin : CDVPlugin
Expand All @@ -55,15 +55,15 @@ @implementation PushPlugin : CDVPlugin

-(void)initRegistration;
{
[[FIRInstanceID instanceID] instanceIDWithHandler:^(FIRInstanceIDResult * _Nullable result, NSError * _Nullable error) {
[[FIRMessaging messaging] tokenWithCompletion:^(NSString *token, NSError *error) {
if (error != nil) {
NSLog(@"Error fetching remote instance ID: %@", error);
NSLog(@"Error getting FCM registration token: %@", error);
} else {
NSLog(@"Remote instance ID (FCM Registration) Token: %@", result.token);
NSLog(@"FCM registration token: %@", token);

[self setFcmRegistrationToken: result.token];
[self setFcmRegistrationToken: token];

NSString* message = [NSString stringWithFormat:@"Remote InstanceID token: %@", result.token];
NSString* message = [NSString stringWithFormat:@"Remote InstanceID token: %@", token];

id topics = [self fcmTopics];
if (topics != nil) {
Expand All @@ -74,7 +74,7 @@ -(void)initRegistration;
}
}

[self registerWithToken:result.token];
[self registerWithToken: token];
}
}];
}
Expand All @@ -90,13 +90,6 @@ - (void)onTokenRefresh {
}

// contains error info
- (void)sendDataMessageFailure:(NSNotification *)notification {
NSLog(@"sendDataMessageFailure");
}
- (void)sendDataMessageSuccess:(NSNotification *)notification {
NSLog(@"sendDataMessageSuccess");
}

- (void)didSendDataMessageWithID:messageID {
NSLog(@"didSendDataMessageWithID");
}
Expand All @@ -105,13 +98,6 @@ - (void)willSendDataMessageWithID:messageID error:error {
NSLog(@"willSendDataMessageWithID");
}

- (void)didDeleteMessagesOnServer {
NSLog(@"didDeleteMessagesOnServer");
// Some messages sent to this device were deleted on the GCM server before reception, likely
// because the TTL expired. The client should notify the app server of this, so that the app
// server can resend those messages.
}

- (void)unregister:(CDVInvokedUrlCommand*)command;
{
NSArray* topics = [command argumentAtIndex:0];
Expand Down Expand Up @@ -178,20 +164,8 @@ - (void)init:(CDVInvokedUrlCommand*)command;
} else {
NSLog(@"Push Plugin VoIP missing or false");
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(onTokenRefresh)
name:kFIRInstanceIDTokenRefreshNotification object:nil];

[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(sendDataMessageFailure:)
name:FIRMessagingSendErrorNotification object:nil];

[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(sendDataMessageSuccess:)
name:FIRMessagingSendSuccessNotification object:nil];

[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(didDeleteMessagesOnServer)
name:FIRMessagingMessagesDeletedNotification object:nil];
addObserver:self selector:@selector(onTokenRefresh)
name:FIRMessagingRegistrationTokenRefreshedNotification object:nil];

[self.commandDelegate runInBackground:^ {
NSLog(@"Push Plugin register called");
Expand Down

0 comments on commit 10eee49

Please sign in to comment.