Skip to content

Commit

Permalink
Merge branch 'release/1.0.0-beta.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
RaddishIoW committed Apr 5, 2023
2 parents cd785f9 + 6e67c7d commit c0b7ca2
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 46 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [1.0.0-beta.1](https://github.com/HaylLtd/capacitor-push-notifications/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (2023-04-05)



# [1.0.0-alpha.2](https://github.com/HaylLtd/capacitor-push-notifications/compare/1.0.0-alpha.1...v1.0.0-alpha.2) (2023-04-04)


Expand Down
44 changes: 29 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func application(_ application: UIApplication, didFailToRegisterForRemoteNotific

## Android

The Push Notification API uses [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) SDK for handling notifications. See [Set up a Firebase Cloud Messaging client app on Android](https://firebase.google.com/docs/cloud-messaging/android/client) and follow the instructions for creating a Firebase project and registering your application. There is no need to add the Firebase SDK to your app or edit your app manifest - the Push Notifications provides that for you. All that is required is your Firebase project's `google-services.json` file added to the module (app-level) directory of your app.
The Push Notification API uses [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) SDK for handling notifications. See [Set up a Firebase Cloud Messaging client app on Android](https://firebase.google.com/docs/cloud-messaging/android/client) and follow the instructions for creating a Firebase project and registering your application. There is no need to add the Firebase SDK to your app or edit your app manifest - the Push Notifications provides that for you. All that is required is your Firebase project's `google-services.json` file added to the module (app-level) directory of your app.

### Variables

Expand Down Expand Up @@ -88,7 +88,7 @@ In `capacitor.config.json`:
In `capacitor.config.ts`:

```ts
/// <reference types="@capacitor/push-notifications" />
/// <reference types="@haylltd/capacitor-push-notifications" />

import { CapacitorConfig } from '@capacitor/cli';

Expand All @@ -110,17 +110,21 @@ export default config;
</docgen-config>

## Silent Push Notifications / Data-only Notifications

#### iOS

This plugin does not support iOS Silent Push (Remote Notifications). We recommend using native code solutions for handling these types of notifications, see [Pushing Background Updates to Your App](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app).

#### Android
This plugin does support data-only notifications, but will NOT call `pushNotificationReceived` if the app has been killed. To handle this scenario, you will need to create a service that extends `FirebaseMessagingService`, see [Handling FCM Messages](https://firebase.google.com/docs/cloud-messaging/android/receive).

This plugin does support data-only notifications, but will NOT call `pushNotificationReceived` if the app has been killed. To handle this scenario, you will need to create a service that extends `FirebaseMessagingService`, see [Handling FCM Messages](https://firebase.google.com/docs/cloud-messaging/android/receive).

## Common Issues

On Android, there are various system and app states that can affect the delivery of push notifications:

* If the device has entered [Doze](https://developer.android.com/training/monitoring-device-state/doze-standby) mode, your application may have restricted capabilities. To increase the chance of your notification being received, consider using [FCM high priority messages](https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message).
* There are differences in behavior between development and production. Try testing your app outside of being launched by Android Studio. Read more [here](https://stackoverflow.com/a/50238790/1351469).
- If the device has entered [Doze](https://developer.android.com/training/monitoring-device-state/doze-standby) mode, your application may have restricted capabilities. To increase the chance of your notification being received, consider using [FCM high priority messages](https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message).
- There are differences in behavior between development and production. Try testing your app outside of being launched by Android Studio. Read more [here](https://stackoverflow.com/a/50238790/1351469).

---

Expand All @@ -138,14 +142,24 @@ const addListeners = async () => {
console.error('Registration error: ', err.error);
});

await PushNotifications.addListener('pushNotificationReceived', notification => {
console.log('Push notification received: ', notification);
});

await PushNotifications.addListener('pushNotificationActionPerformed', notification => {
console.log('Push notification action performed', notification.actionId, notification.inputValue);
});
}
await PushNotifications.addListener(
'pushNotificationReceived',
notification => {
console.log('Push notification received: ', notification);
},
);

await PushNotifications.addListener(
'pushNotificationActionPerformed',
notification => {
console.log(
'Push notification action performed',
notification.actionId,
notification.inputValue,
);
},
);
};

const registerNotifications = async () => {
let permStatus = await PushNotifications.checkPermissions();
Expand All @@ -159,12 +173,12 @@ const registerNotifications = async () => {
}

await PushNotifications.register();
}
};

const getDeliveredNotifications = async () => {
const notificationList = await PushNotifications.getDeliveredNotifications();
console.log('delivered notifications', notificationList);
}
};
```

## API
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@haylltd/capacitor-push-notifications",
"version": "1.0.0-alpha.2",
"version": "1.0.0-beta.1",
"description": "Improved push notification support for Capacitor apps",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -48,14 +48,14 @@
"@capacitor/android": "^4.0.0",
"@capacitor/cli": "^4.0.0",
"@capacitor/core": "^4.0.0",
"@capacitor/docgen": "^0.0.18",
"@capacitor/docgen": "^0.2.0",
"@capacitor/ios": "^4.0.0",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "^1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"conventional-changelog-cli": "^2.2.2",
"eslint": "^7.11.0",
"prettier": "~2.3.0",
"prettier": "~2.8.0",
"prettier-plugin-java": "~1.0.2",
"rimraf": "^3.0.2",
"rollup": "^2.32.0",
Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,24 @@ export interface PushNotificationsPlugin {
* notification permissions, use `requestPermissions()` first.
*
* @since 1.0.0
* @return {Promise<void>}
*/
register(): Promise<void>;

/**
* Get a list of notifications that are visible on the notifications screen.
*
* @since 1.0.0
* @return {Promise<DeliveredNotifications>}
*/
getDeliveredNotifications(): Promise<DeliveredNotifications>;

/**
* Remove the specified notifications from the notifications screen.
*
* @since 1.0.0
* @param {DeliveredNotifications} delivered
* @return {Promise<void>}
*/
removeDeliveredNotifications(
delivered: DeliveredNotifications,
Expand All @@ -98,6 +102,7 @@ export interface PushNotificationsPlugin {
* Remove all the notifications from the notifications screen.
*
* @since 1.0.0
* @return {Promise<void>}
*/
removeAllDeliveredNotifications(): Promise<void>;

Expand All @@ -107,6 +112,8 @@ export interface PushNotificationsPlugin {
* Only available on Android O or newer (SDK 26+).
*
* @since 1.0.0
* @param {Channel} channel
* @return {Promise<void>}
*/
createChannel(channel: Channel): Promise<void>;

Expand All @@ -116,6 +123,8 @@ export interface PushNotificationsPlugin {
* Only available on Android O or newer (SDK 26+).
*
* @since 1.0.0
* @param { {string} id } args
* @return {Promise<void>}
*/
deleteChannel(args: { id: string }): Promise<void>;

Expand All @@ -125,6 +134,7 @@ export interface PushNotificationsPlugin {
* Only available on Android O or newer (SDK 26+).
*
* @since 1.0.0
* @return {Promise<ListChannelsResult>}
*/
listChannels(): Promise<ListChannelsResult>;

Expand All @@ -136,6 +146,7 @@ export interface PushNotificationsPlugin {
* to display notifications, use local-notifications plugin.
*
* @since 1.0.0
* @return {Promise<PermissionStatus>}
*/
checkPermissions(): Promise<PermissionStatus>;

Expand All @@ -151,6 +162,7 @@ export interface PushNotificationsPlugin {
* the permission without prompting again.
*
* @since 1.0.0
* @return {Promise<PermissionStatus>}
*/
requestPermissions(): Promise<PermissionStatus>;

Expand All @@ -160,6 +172,9 @@ export interface PushNotificationsPlugin {
* Provides the push notification token.
*
* @since 1.0.0
* @param {string} eventName
* @param {({Token} token) => void} listenerFunc
* @return {Promise<PluginListenerHandle>}
*/
addListener(
eventName: 'registration',
Expand All @@ -172,6 +187,9 @@ export interface PushNotificationsPlugin {
* Provides an error with the registration problem.
*
* @since 1.0.0
* @param {string} eventName
* @param {({RegistrationError} error) => void} listenerFunc
* @return {Promise<PluginListenerHandle>}
*/
addListener(
eventName: 'registrationError',
Expand All @@ -182,6 +200,9 @@ export interface PushNotificationsPlugin {
* Called when the device receives a push notification.
*
* @since 1.0.0
* @param {string} eventName
* @param {({PushNotificationSchema} notification) => void} listenerFunc
* @return {Promise<PluginListenerHandle>}
*/
addListener(
eventName: 'pushNotificationReceived',
Expand All @@ -192,6 +213,9 @@ export interface PushNotificationsPlugin {
* Called when an action is performed on a push notification.
*
* @since 1.0.0
* @param {string} eventName
* @param {({ActionPerformed} notification) => void} listenerFunc
* @return {Promise<PluginListenerHandle>}
*/
addListener(
eventName: 'pushNotificationActionPerformed',
Expand All @@ -202,6 +226,7 @@ export interface PushNotificationsPlugin {
* Remove all native listeners for this plugin.
*
* @since 1.0.0
* @return {Promise<void>}
*/
removeAllListeners(): Promise<void>;
}
Expand Down
13 changes: 0 additions & 13 deletions src/web.ts

This file was deleted.

0 comments on commit c0b7ca2

Please sign in to comment.