Skip to content

Commit a2ba90c

Browse files
authored
Merge pull request #2 from spoonconsulting/ios-fix
Ios fix
2 parents 1d23434 + a977544 commit a2ba90c

File tree

8 files changed

+65
-38
lines changed

8 files changed

+65
-38
lines changed

.github/workflows/npm-publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Node.js Package
2+
on: push
3+
jobs:
4+
publish:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- uses: bahmutov/npm-install@v1
9+
- id: publish
10+
uses: JS-DevTools/npm-publish@v2
11+
with:
12+
token: ${{ secrets.npm_token }}

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
{
2-
"name": "cordova-plugin-firebase-messaging",
3-
"version": "8.0.1",
2+
"name": "@spoonconsulting/cordova-plugin-firebase-messaging",
3+
"version": "1.0.0",
44
"description": "Cordova plugin for Firebase Messaging",
55
"types": "./types/index.d.ts",
66
"cordova": {
7-
"id": "cordova-plugin-firebase-messaging",
7+
"id": "@spoonconsulting/cordova-plugin-firebase-messaging",
88
"platforms": [
99
"ios",
1010
"android"
1111
]
1212
},
1313
"repository": {
1414
"type": "git",
15-
"url": "git+https://github.com/chemerisuk/cordova-plugin-firebase-messaging.git"
15+
"url": "git+https://github.com/spoonconsulting/cordova-plugin-firebase-messaging.git"
1616
},
17-
"author": "Maksim Chemerisuk <chemerisuk@gmail.com> (https://github.com/chemerisuk)",
17+
"publishConfig": {
18+
"access": "public"
19+
},
20+
"author": "Maksim Chemerisuk <chemerisuk@gmail.com> (https://github.com/chemerisuk) & Hashir Rajah",
1821
"license": "MIT",
1922
"bugs": {
20-
"url": "https://github.com/chemerisuk/cordova-plugin-firebase-messaging/issues"
23+
"url": "https://github.com/spoonconsulting/cordova-plugin-firebase-messaging/issues"
2124
},
22-
"homepage": "https://github.com/chemerisuk/cordova-plugin-firebase-messaging#readme",
23-
"funding": "https://github.com/chemerisuk/cordova-plugin-firebase-messaging?sponsor=1",
25+
"homepage": "https://github.com/spoonconsulting/cordova-plugin-firebase-messaging#readme",
2426
"keywords": [
2527
"cordova",
2628
"firebase",
@@ -32,16 +34,5 @@
3234
"cordova-android",
3335
"cordova-ios"
3436
],
35-
"scripts": {
36-
"preversion": "npm run docs && rm -rf docs",
37-
"version": "perl -i -pe 's/(version=)\"\\d+\\.\\d+\\.\\d+\"/$1\"'$npm_package_version'\"$2/' plugin.xml && git add .",
38-
"postversion": "git push && git push --tags",
39-
"predocs": "tsc www/* --declaration --allowJs --checkJs --lib es2015,dom --emitDeclarationOnly --outDir types",
40-
"docs": "typedoc && perl -i -pe 's/README.md#/#/g' ./docs/README.md",
41-
"postdocs": "perl -i -0pe 's/(<!-- TypedocGenerated -->).*/$1\n\n/gms' README.md && cat ./docs/README.md >> README.md"
42-
},
43-
"devDependencies": {
44-
"typedoc": "^0.23.9",
45-
"typedoc-plugin-markdown": "^3.13.4"
46-
}
37+
"scripts": {}
4738
}

plugin.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
22
xmlns:android="http://schemas.android.com/apk/res/android"
3-
id="cordova-plugin-firebase-messaging"
4-
version="8.0.1">
3+
id="@spoonconsulting/cordova-plugin-firebase-messaging"
4+
version="1.0.0">
55

66
<name>FirebaseMessagingPlugin</name>
77
<description>Cordova plugin for Firebase Cloud Messaging</description>
88
<license>MIT</license>
99
<keywords>cordova</keywords>
10-
<repo>https://github.com/chemerisuk/cordova-plugin-firebase-messaging</repo>
11-
<issue>https://github.com/chemerisuk/cordova-plugin-firebase-messaging/issues</issue>
10+
<repo>https://github.com/spoonconsulting/cordova-plugin-firebase-messaging</repo>
11+
<issue>https://github.com/spoonconsulting/cordova-plugin-firebase-messaging/issues</issue>
1212

1313
<js-module src="www/FirebaseMessaging.js" name="FirebaseMessaging">
1414
<merges target="cordova.plugins.firebase.messaging" />
@@ -62,7 +62,7 @@ xmlns:android="http://schemas.android.com/apk/res/android"
6262

6363
<config-file target="res/xml/config.xml" parent="/*">
6464
<feature name="FirebaseMessaging">
65-
<param name="android-package" value="by.chemerisuk.cordova.firebase.FirebaseMessagingPlugin" />
65+
<param name="android-package" value="com.spoon.cordova.firebase.FirebaseMessagingPlugin" />
6666
<param name="onload" value="true" />
6767
</feature>
6868
</config-file>
@@ -74,7 +74,7 @@ xmlns:android="http://schemas.android.com/apk/res/android"
7474
</config-file>
7575

7676
<config-file target="AndroidManifest.xml" parent="/manifest/application">
77-
<service android:name="by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService" android:exported="false">
77+
<service android:name="com.spoon.cordova.firebase.FirebaseMessagingPluginService" android:exported="false">
7878
<intent-filter>
7979
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
8080
</intent-filter>
@@ -89,9 +89,9 @@ xmlns:android="http://schemas.android.com/apk/res/android"
8989
<framework src="me.leolin:ShortcutBadger:1.1.22@aar"/>
9090

9191
<source-file src="src/android/FirebaseMessagingPlugin.java"
92-
target-dir="src/by/chemerisuk/cordova/firebase/" />
92+
target-dir="src/com/spoon/cordova/firebase/" />
9393
<source-file src="src/android/FirebaseMessagingPluginService.java"
94-
target-dir="src/by/chemerisuk/cordova/firebase" />
94+
target-dir="src/com/spoon/cordova/firebase" />
9595
</platform>
9696

9797
</plugin>

src/android/FirebaseMessagingPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
package by.chemerisuk.cordova.firebase;
2+
package com.spoon.cordova.firebase;
33

44
import android.Manifest;
55
import android.app.NotificationManager;

src/android/FirebaseMessagingPluginService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package by.chemerisuk.cordova.firebase;
1+
package com.spoon.cordova.firebase;
22

33
import android.app.NotificationChannel;
44
import android.app.NotificationManager;
@@ -26,10 +26,10 @@
2626
public class FirebaseMessagingPluginService extends FirebaseMessagingService {
2727
private static final String TAG = "FCMPluginService";
2828

29-
public static final String ACTION_FCM_MESSAGE = "by.chemerisuk.cordova.firebase.ACTION_FCM_MESSAGE";
30-
public static final String EXTRA_FCM_MESSAGE = "by.chemerisuk.cordova.firebase.EXTRA_FCM_MESSAGE";
31-
public static final String ACTION_FCM_TOKEN = "by.chemerisuk.cordova.firebase.ACTION_FCM_TOKEN";
32-
public static final String EXTRA_FCM_TOKEN = "by.chemerisuk.cordova.firebase.EXTRA_FCM_TOKEN";
29+
public static final String ACTION_FCM_MESSAGE = "com.spoon.cordova.firebase.ACTION_FCM_MESSAGE";
30+
public static final String EXTRA_FCM_MESSAGE = "com.spoon.cordova.firebase.EXTRA_FCM_MESSAGE";
31+
public static final String ACTION_FCM_TOKEN = "com.spoon.cordova.firebase.ACTION_FCM_TOKEN";
32+
public static final String EXTRA_FCM_TOKEN = "com.spoon.cordova.firebase.EXTRA_FCM_TOKEN";
3333
public final static String NOTIFICATION_ICON_KEY = "com.google.firebase.messaging.default_notification_icon";
3434
public final static String NOTIFICATION_COLOR_KEY = "com.google.firebase.messaging.default_notification_color";
3535
public final static String NOTIFICATION_CHANNEL_KEY = "com.google.firebase.messaging.default_notification_channel_id";

src/ios/AppDelegate+FirebaseMessagingPlugin.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#import "FirebaseMessagingPlugin.h"
33
#import <objc/runtime.h>
44

5+
@import FirebaseCore;
6+
57
@implementation AppDelegate (FirebaseMessagingPlugin)
68

79
// Borrowed from http://nshipster.com/method-swizzling/
@@ -36,8 +38,21 @@ + (void)load {
3638
- (BOOL)identity_application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
3739
// always call original method implementation first
3840
BOOL handled = [self identity_application:application didFinishLaunchingWithOptions:launchOptions];
41+
if(![FIRApp defaultApp]) {
42+
[FIRApp configure];
43+
}
3944

45+
[FIRMessaging messaging].delegate = self;
4046
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
47+
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
48+
UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
49+
[[UNUserNotificationCenter currentNotificationCenter]
50+
requestAuthorizationWithOptions:authOptions
51+
completionHandler:^(BOOL granted, NSError * _Nullable error) {
52+
// ...
53+
}];
54+
55+
[application registerForRemoteNotifications];
4156

4257
// if (launchOptions) {
4358
// NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];

src/ios/FirebaseMessagingPlugin.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ @implementation FirebaseMessagingPlugin
99

1010
- (void)pluginInitialize {
1111
NSLog(@"Starting Firebase Messaging plugin");
12-
13-
if(![FIRApp defaultApp]) {
14-
[FIRApp configure];
15-
}
1612
}
1713

1814
- (void)requestPermission:(CDVInvokedUrlCommand *)command {

0 commit comments

Comments
 (0)