Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Version update #2941

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</js-module>
<engines>
<engine name="cordova" version=">=7.1.0"/>
<engine name="cordova-android" version=">=7.1.0"/>
<engine name="cordova-android" version=">=8.1.0"/>
<engine name="cordova-ios" version=">=4.5.0"/>
</engines>
<platform name="android">
Expand Down Expand Up @@ -43,11 +43,11 @@
</service>
</config-file>
<preference name="ANDROID_SUPPORT_V13_VERSION" default="27.+"/>
<preference name="FCM_VERSION" default="17.0.+"/>
<preference name="FCM_VERSION" default="20.2.4"/>
<framework src="com.android.support:support-v13:$ANDROID_SUPPORT_V13_VERSION"/>
<framework src="me.leolin:ShortcutBadger:1.1.17@aar"/>
<framework src="com.google.firebase:firebase-messaging:$FCM_VERSION"/>
<dependency id="cordova-support-google-services" version="~1.3.1"/>
<dependency id="cordova-support-google-services" version="~1.4.0"/>
<dependency id="phonegap-plugin-multidex" version="~1.0.0"/>
<source-file src="src/android/com/adobe/phonegap/push/FCMService.java" target-dir="src/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/PushConstants.java" target-dir="src/com/adobe/phonegap/push/"/>
Expand Down Expand Up @@ -86,7 +86,7 @@
<source-file src="src/ios/PushPlugin.m"/>
<header-file src="src/ios/AppDelegate+notification.h"/>
<header-file src="src/ios/PushPlugin.h"/>
<framework src="FirebaseMessaging" type="podspec" spec="~> 2.0.0"/>
<framework src="FirebaseMessaging" type="podspec" spec="~> 4.0"/>
<framework src="PushKit.framework"/>
</platform>
<platform name="windows">
Expand Down
42 changes: 20 additions & 22 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@

#import "PushPlugin.h"
#import "AppDelegate+notification.h"
@import FirebaseInstanceID;
@import FirebaseMessaging;
@import FirebaseAnalytics;
@import Firebase;

@implementation PushPlugin : CDVPlugin

Expand All @@ -53,26 +51,27 @@ @implementation PushPlugin : CDVPlugin

-(void)initRegistration;
{
NSString * registrationToken = [[FIRInstanceID instanceID] token];

if (registrationToken != nil) {
NSLog(@"FCM Registration Token: %@", registrationToken);
[self setFcmRegistrationToken: registrationToken];

id topics = [self fcmTopics];
if (topics != nil) {
for (NSString *topic in topics) {
NSLog(@"subscribe to topic: %@", topic);
id pubSub = [FIRMessaging messaging];
[pubSub subscribeToTopic:topic];
[[FIRInstanceID instanceID] instanceIDWithHandler:^(FIRInstanceIDResult * _Nullable result, NSError * _Nullable error) {
NSString * registrationToken = result.token;

if (registrationToken != nil) {
NSLog(@"FCM Registration Token: %@", registrationToken);
[self setFcmRegistrationToken: registrationToken];

id topics = [self fcmTopics];
if (topics != nil) {
for (NSString *topic in topics) {
NSLog(@"subscribe to topic: %@", topic);
id pubSub = [FIRMessaging messaging];
[pubSub subscribeToTopic:topic];
}
}
}

[self registerWithToken:registrationToken];
} else {
NSLog(@"FCM token is null");
}

[self registerWithToken:registrationToken];
} else {
NSLog(@"FCM token is null");
}
}];
}

// FCM refresh token
Expand All @@ -81,7 +80,6 @@ - (void)onTokenRefresh {
#if !TARGET_IPHONE_SIMULATOR
// A rotation of the registration tokens is happening, so the app needs to request a new token.
NSLog(@"The FCM registration token needs to be changed.");
[[FIRInstanceID instanceID] token];
[self initRegistration];
#endif
}
Expand Down