capacitor-plugin-silent-notifications 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorPluginSilentNotifications.podspec +17 -0
- package/README.md +122 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/bubblelabs/silentnotifications/CapacitorSilentNotifications.java +11 -0
- package/android/src/main/java/com/bubblelabs/silentnotifications/CapacitorSilentNotificationsPlugin.java +22 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +107 -0
- package/dist/esm/definitions.d.ts +29 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/plugin.cjs.js +10 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +13 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/CapacitorSilentNotifications.swift +8 -0
- package/ios/Plugin/CapacitorSilentNotificationsPlugin.h +10 -0
- package/ios/Plugin/CapacitorSilentNotificationsPlugin.m +8 -0
- package/ios/Plugin/CapacitorSilentNotificationsPlugin.swift +29 -0
- package/ios/Plugin/Info.plist +24 -0
- package/package.json +78 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CapacitorPluginSilentNotifications'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '12.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# capacitor-plugin-silent-notifications
|
|
2
|
+
|
|
3
|
+
Allows a Capacitor application to handle iOS remote/silent push notifications.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
- Must be using iOS 13 or later
|
|
7
|
+
- Your app must be setup to receive push notifications (you need the device token)
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install capacitor-plugin-silent-notifications
|
|
13
|
+
npx cap sync
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Add to AppDelete.swift
|
|
17
|
+
```swift
|
|
18
|
+
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
|
19
|
+
// debug
|
|
20
|
+
print("Received by: didReceiveRemoteNotification w/ fetchCompletionHandler")
|
|
21
|
+
|
|
22
|
+
// Perform background operation, need to create a plugin
|
|
23
|
+
NotificationCenter.default.post(name: Notification.Name(rawValue: "silentNotificationReceived"), object: nil, userInfo: userInfo)
|
|
24
|
+
|
|
25
|
+
// Give the listener a few seconds to complete, system allows for 30 - we give 25. The system will kill this after 30 seconds.
|
|
26
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 25) {
|
|
27
|
+
// Execute after 25 seconds
|
|
28
|
+
completionHandler(.newData)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// we just add this to deal with an iOS simulator bug, this method is deprecated as of iOS 13
|
|
33
|
+
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
|
34
|
+
// debug
|
|
35
|
+
print("Received by: performFetchWithCompletionHandler")
|
|
36
|
+
|
|
37
|
+
// Perform background operation, need to create a plugin
|
|
38
|
+
NotificationCenter.default.post(name: Notification.Name(rawValue: "silentNotificationReceived"), object: nil, userInfo: nil)
|
|
39
|
+
|
|
40
|
+
// Give the listener a few seconds to complete, system allows for 30 - we give 25. The system will kill this after 30 seconds.
|
|
41
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 25) {
|
|
42
|
+
// Execute after 25 seconds
|
|
43
|
+
completionHandler(.newData)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Add the listener to your Capacitor app
|
|
49
|
+
```typescript
|
|
50
|
+
import { CapacitorSilentNotifications } from 'capacitor-plugin-silent-notifications'
|
|
51
|
+
|
|
52
|
+
CapacitorSilentNotifications.addListener('silentNotificationReceived', async (payload) => {
|
|
53
|
+
// do something with the notification payload here
|
|
54
|
+
console.log('silentNotificationReceived', payload);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
<docgen-index>
|
|
61
|
+
|
|
62
|
+
* [`addListener('silentNotificationReceived', ...)`](#addlistenersilentnotificationreceived)
|
|
63
|
+
* [`removeAllListeners()`](#removealllisteners)
|
|
64
|
+
* [Interfaces](#interfaces)
|
|
65
|
+
|
|
66
|
+
</docgen-index>
|
|
67
|
+
|
|
68
|
+
<docgen-api>
|
|
69
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
70
|
+
|
|
71
|
+
### addListener('silentNotificationReceived', ...)
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
addListener(eventName: 'silentNotificationReceived', listenerFunc: (options: Options) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Listens to events associated with Silent Notifications
|
|
78
|
+
and notifies the listenerFunc if a background notification has been received.
|
|
79
|
+
|
|
80
|
+
| Param | Type | Description |
|
|
81
|
+
| ------------------ | ----------------------------------------------------------------- | ----------------------------------------------- |
|
|
82
|
+
| **`eventName`** | <code>'silentNotificationReceived'</code> | Name of the event |
|
|
83
|
+
| **`listenerFunc`** | <code>(options: <a href="#options">Options</a>) => void</code> | Function to execute when listener gets notified |
|
|
84
|
+
|
|
85
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>> & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
86
|
+
|
|
87
|
+
**Since:** 1.0.0
|
|
88
|
+
|
|
89
|
+
--------------------
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### removeAllListeners()
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
removeAllListeners() => Promise<void>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Remove all listeners for this plugin.
|
|
99
|
+
|
|
100
|
+
**Since:** 1.0.0
|
|
101
|
+
|
|
102
|
+
--------------------
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### Interfaces
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
#### PluginListenerHandle
|
|
109
|
+
|
|
110
|
+
| Prop | Type |
|
|
111
|
+
| ------------ | ----------------------------------------- |
|
|
112
|
+
| **`remove`** | <code>() => Promise<void></code> |
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
#### Options
|
|
116
|
+
|
|
117
|
+
| Prop | Type | Description |
|
|
118
|
+
| -------------- | ---------------- | --------------------------------------------------------------------------------------- |
|
|
119
|
+
| **`userInfo`** | <code>any</code> | Provide a key-value object that contains information sent with the remote notification. |
|
|
120
|
+
| **`object`** | <code>any</code> | Return the object sent with the data |
|
|
121
|
+
|
|
122
|
+
</docgen-api>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
jcenter()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:4.2.1'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
|
|
22
|
+
defaultConfig {
|
|
23
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
|
|
24
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
|
|
25
|
+
versionCode 1
|
|
26
|
+
versionName "1.0"
|
|
27
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
28
|
+
}
|
|
29
|
+
buildTypes {
|
|
30
|
+
release {
|
|
31
|
+
minifyEnabled false
|
|
32
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
lintOptions {
|
|
36
|
+
abortOnError false
|
|
37
|
+
}
|
|
38
|
+
compileOptions {
|
|
39
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
40
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
repositories {
|
|
45
|
+
google()
|
|
46
|
+
mavenCentral()
|
|
47
|
+
jcenter()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.bubblelabs.silentnotifications;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Plugin;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import com.getcapacitor.PluginMethod;
|
|
7
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
|
|
9
|
+
@CapacitorPlugin(name = "CapacitorSilentNotifications")
|
|
10
|
+
public class CapacitorSilentNotificationsPlugin extends Plugin {
|
|
11
|
+
|
|
12
|
+
private CapacitorSilentNotifications implementation = new CapacitorSilentNotifications();
|
|
13
|
+
|
|
14
|
+
@PluginMethod
|
|
15
|
+
public void echo(PluginCall call) {
|
|
16
|
+
String value = call.getString("value");
|
|
17
|
+
|
|
18
|
+
JSObject ret = new JSObject();
|
|
19
|
+
ret.put("value", implementation.echo(value));
|
|
20
|
+
call.resolve(ret);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "CapacitorSilentNotificationsPlugin",
|
|
4
|
+
"slug": "capacitorsilentnotificationsplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "addListener",
|
|
10
|
+
"signature": "(eventName: 'silentNotificationReceived', listenerFunc: (options: Options) => void) => Promise<PluginListenerHandle> & PluginListenerHandle",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "eventName",
|
|
14
|
+
"docs": "Name of the event",
|
|
15
|
+
"type": "'silentNotificationReceived'"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "listenerFunc",
|
|
19
|
+
"docs": "Function to execute when listener gets notified",
|
|
20
|
+
"type": "(options: Options) => void"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"returns": "Promise<PluginListenerHandle> & PluginListenerHandle",
|
|
24
|
+
"tags": [
|
|
25
|
+
{
|
|
26
|
+
"name": "since",
|
|
27
|
+
"text": "1.0.0"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "param",
|
|
31
|
+
"text": "eventName Name of the event"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "param",
|
|
35
|
+
"text": "listenerFunc Function to execute when listener gets notified"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"docs": "Listens to events associated with Silent Notifications\nand notifies the listenerFunc if a background notification has been received.",
|
|
39
|
+
"complexTypes": [
|
|
40
|
+
"PluginListenerHandle",
|
|
41
|
+
"Options"
|
|
42
|
+
],
|
|
43
|
+
"slug": "addlistenersilentnotificationreceived"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "removeAllListeners",
|
|
47
|
+
"signature": "() => Promise<void>",
|
|
48
|
+
"parameters": [],
|
|
49
|
+
"returns": "Promise<void>",
|
|
50
|
+
"tags": [
|
|
51
|
+
{
|
|
52
|
+
"name": "since",
|
|
53
|
+
"text": "1.0.0"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"docs": "Remove all listeners for this plugin.",
|
|
57
|
+
"complexTypes": [],
|
|
58
|
+
"slug": "removealllisteners"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"properties": []
|
|
62
|
+
},
|
|
63
|
+
"interfaces": [
|
|
64
|
+
{
|
|
65
|
+
"name": "PluginListenerHandle",
|
|
66
|
+
"slug": "pluginlistenerhandle",
|
|
67
|
+
"docs": "",
|
|
68
|
+
"tags": [],
|
|
69
|
+
"methods": [],
|
|
70
|
+
"properties": [
|
|
71
|
+
{
|
|
72
|
+
"name": "remove",
|
|
73
|
+
"tags": [],
|
|
74
|
+
"docs": "",
|
|
75
|
+
"complexTypes": [],
|
|
76
|
+
"type": "() => Promise<void>"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "Options",
|
|
82
|
+
"slug": "options",
|
|
83
|
+
"docs": "",
|
|
84
|
+
"tags": [],
|
|
85
|
+
"methods": [],
|
|
86
|
+
"properties": [
|
|
87
|
+
{
|
|
88
|
+
"name": "userInfo",
|
|
89
|
+
"tags": [],
|
|
90
|
+
"docs": "Provide a key-value object that contains information sent with the remote notification.",
|
|
91
|
+
"complexTypes": [],
|
|
92
|
+
"type": "any"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "object",
|
|
96
|
+
"tags": [],
|
|
97
|
+
"docs": "Return the object sent with the data",
|
|
98
|
+
"complexTypes": [],
|
|
99
|
+
"type": "any"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"enums": [],
|
|
105
|
+
"typeAliases": [],
|
|
106
|
+
"pluginConfigs": []
|
|
107
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PluginListenerHandle } from "@capacitor/core";
|
|
2
|
+
export interface CapacitorSilentNotificationsPlugin {
|
|
3
|
+
/**
|
|
4
|
+
* Listens to events associated with Silent Notifications
|
|
5
|
+
* and notifies the listenerFunc if a background notification has been received.
|
|
6
|
+
*
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* @param eventName Name of the event
|
|
10
|
+
* @param listenerFunc Function to execute when listener gets notified
|
|
11
|
+
*/
|
|
12
|
+
addListener(eventName: 'silentNotificationReceived', listenerFunc: (options: Options) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
|
|
13
|
+
/**
|
|
14
|
+
* Remove all listeners for this plugin.
|
|
15
|
+
*
|
|
16
|
+
* @since 1.0.0
|
|
17
|
+
*/
|
|
18
|
+
removeAllListeners(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export interface Options {
|
|
21
|
+
/**
|
|
22
|
+
* Provide a key-value object that contains information sent with the remote notification.
|
|
23
|
+
*/
|
|
24
|
+
userInfo?: any;
|
|
25
|
+
/**
|
|
26
|
+
* Return the object sent with the data
|
|
27
|
+
*/
|
|
28
|
+
object?: any;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface CapacitorSilentNotificationsPlugin {\n // echo(options: { value: string }): Promise<{ value: string }>;\n /**\n * Listens to events associated with Silent Notifications\n * and notifies the listenerFunc if a background notification has been received.\n *\n * @since 1.0.0\n *\n * @param eventName Name of the event\n * @param listenerFunc Function to execute when listener gets notified\n */\n addListener(\n eventName: 'silentNotificationReceived',\n listenerFunc: (options: Options) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Not currently in use.\n */\n // markCompleted(): Promise<any>;\n}\n\nexport interface Options {\n /**\n * Provide a key-value object that contains information sent with the remote notification.\n */\n userInfo?: any;\n\n /**\n * Return the object sent with the data\n */\n object?: any;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,4BAA4B,GAAG,cAAc,CAAqC,8BAA8B,CAAC,CAAC;AAExH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,4BAA4B,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapacitorSilentNotificationsPlugin } from './definitions';\n\nconst CapacitorSilentNotifications = registerPlugin<CapacitorSilentNotificationsPlugin>('CapacitorSilentNotifications');\n\nexport * from './definitions';\nexport { CapacitorSilentNotifications };\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
|
|
7
|
+
const CapacitorSilentNotifications = core.registerPlugin('CapacitorSilentNotifications');
|
|
8
|
+
|
|
9
|
+
exports.CapacitorSilentNotifications = CapacitorSilentNotifications;
|
|
10
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorSilentNotifications = registerPlugin('CapacitorSilentNotifications');\nexport * from './definitions';\nexport { CapacitorSilentNotifications };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;;;;AACK,MAAC,4BAA4B,GAAGA,mBAAc,CAAC,8BAA8B;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var capacitorCapacitorSilentNotifications = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const CapacitorSilentNotifications = core.registerPlugin('CapacitorSilentNotifications');
|
|
5
|
+
|
|
6
|
+
exports.CapacitorSilentNotifications = CapacitorSilentNotifications;
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
+
|
|
10
|
+
return exports;
|
|
11
|
+
|
|
12
|
+
})({}, capacitorExports);
|
|
13
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorSilentNotifications = registerPlugin('CapacitorSilentNotifications');\nexport * from './definitions';\nexport { CapacitorSilentNotifications };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;AACK,OAAC,4BAA4B,GAAGA,mBAAc,CAAC,8BAA8B;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
//! Project version number for Plugin.
|
|
4
|
+
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
+
|
|
6
|
+
//! Project version string for Plugin.
|
|
7
|
+
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
+
|
|
9
|
+
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <Capacitor/Capacitor.h>
|
|
3
|
+
|
|
4
|
+
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
+
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
+
CAP_PLUGIN(CapacitorSilentNotificationsPlugin, "CapacitorSilentNotifications",
|
|
7
|
+
CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
|
|
8
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
*/
|
|
8
|
+
@objc(CapacitorSilentNotificationsPlugin)
|
|
9
|
+
public class CapacitorSilentNotificationsPlugin: CAPPlugin {
|
|
10
|
+
private let implementation = CapacitorSilentNotifications()
|
|
11
|
+
|
|
12
|
+
public override func load() {
|
|
13
|
+
NotificationCenter.default.addObserver(self,
|
|
14
|
+
selector: #selector(self.onBackgoundNotification(notification:)),
|
|
15
|
+
name: NSNotification.Name("silentNotificationReceived"), object: nil)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@objc public func onBackgoundNotification(notification: Notification) {
|
|
19
|
+
debugPrint(notification)
|
|
20
|
+
self.notifyListeners("silentNotificationReceived", data: notification.userInfo as? [String : Any] ?? ["something": "happened"], retainUntilConsumed: true)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// @objc func echo(_ call: CAPPluginCall) {
|
|
24
|
+
// let value = call.getString("value") ?? ""
|
|
25
|
+
// call.resolve([
|
|
26
|
+
// "value": implementation.echo(value)
|
|
27
|
+
// ])
|
|
28
|
+
// }
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "capacitor-plugin-silent-notifications",
|
|
3
|
+
"version": "0.9.1",
|
|
4
|
+
"description": "Allows an a Capacitor application to handle iOS remote/silent push notifications",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Plugin/",
|
|
14
|
+
"CapacitorPluginSilentNotifications.podspec"
|
|
15
|
+
],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/greenygh0st/capacitor-plugin-silent-notifications.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/greenygh0st/capacitor-plugin-silent-notifications/issues"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"capacitor",
|
|
27
|
+
"plugin",
|
|
28
|
+
"native"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"verify": "npm run verify:ios && npm run verify:web",
|
|
32
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
|
|
33
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
34
|
+
"verify:web": "npm run build",
|
|
35
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
36
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
37
|
+
"eslint": "eslint . --ext ts",
|
|
38
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
39
|
+
"swiftlint": "node-swiftlint",
|
|
40
|
+
"docgen": "docgen --api CapacitorSilentNotificationsPlugin --output-readme README.md --output-json dist/docs.json",
|
|
41
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
|
|
42
|
+
"clean": "rimraf ./dist",
|
|
43
|
+
"watch": "tsc --watch",
|
|
44
|
+
"prepublishOnly": "npm run build"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@capacitor/android": "^3.0.0",
|
|
48
|
+
"@capacitor/core": "^3.0.0",
|
|
49
|
+
"@capacitor/docgen": "^0.0.18",
|
|
50
|
+
"@capacitor/ios": "^3.0.0",
|
|
51
|
+
"@ionic/eslint-config": "^0.3.0",
|
|
52
|
+
"@ionic/prettier-config": "^1.0.1",
|
|
53
|
+
"@ionic/swiftlint-config": "^1.1.2",
|
|
54
|
+
"eslint": "^7.11.0",
|
|
55
|
+
"prettier": "~2.2.0",
|
|
56
|
+
"prettier-plugin-java": "~1.0.0",
|
|
57
|
+
"rimraf": "^3.0.2",
|
|
58
|
+
"rollup": "^2.32.0",
|
|
59
|
+
"swiftlint": "^1.0.1",
|
|
60
|
+
"typescript": "~4.0.3"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@capacitor/core": "^3.0.0"
|
|
64
|
+
},
|
|
65
|
+
"prettier": "@ionic/prettier-config",
|
|
66
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
67
|
+
"eslintConfig": {
|
|
68
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
69
|
+
},
|
|
70
|
+
"capacitor": {
|
|
71
|
+
"ios": {
|
|
72
|
+
"src": "ios"
|
|
73
|
+
},
|
|
74
|
+
"android": {
|
|
75
|
+
"src": "android"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|