cap-remote-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

cap-remote-plugin

Handle remote notifications with ionic capacitor in angular (e.g. user taps on a push notification).

This is only implemented for iOS currently, to handle an issue with capacitor push notifications where pushNotificationActionPerformed is not called on notification tap.

Install

npm install cap-remote-plugin
npx cap sync

Setup

  1. Enable remote notifs for your iOS project Background Modes Remote Notifs

  2. Handle remote notifications in your AppDelegate.swift file

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    print("on remote message called")
    NotificationCenter.default.post(name:Notification.Name("OnRemoteMessage"), object: userInfo);
    completionHandler(UIBackgroundFetchResult.newData)
}
  1. Listen for the event in your typescript
CapRemotePlugin.addListener(
  'OnRemoteNotification',
  (notification: PushNotificationSchema) => {
    console.log('ON REMOTE NOTIFICATION');
    console.log(notification);
  },
);

Readme

Keywords

Package Sidebar

Install

npm i cap-remote-plugin

Weekly Downloads

5

Version

0.0.3

License

MIT

Unpacked Size

15.8 kB

Total Files

27

Last publish

Collaborators

  • jamesonsaunders