Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!(ios): update Firebase Messaging to ~> 8.1.1 #152

Merged
merged 3 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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