#Native push notifications

2 messages · Page 1 of 1 (latest)

sour plinth
#

Hello everybody! 🙂

I am new to electron and desktop development! I am trying to implement a desktop app on all three platforms which has a critical requirement: it has to have push notification support, with push notifications alerting the user of critical events. I cannot use WebSockets (scaling issue), MQTT (scaling issue) or push-receiver (as it seems like a non-official, reverse-engineered solution).

I have tried using pushNotifications.registerForAPNSNotifications() but it seem to give me this error:

Error: 13 NSOSStatusErrorDomain {
NSDebugDescription = "Bundle identifier mismatch";
}

Do you have any idea or recommendation on how to achieve this? Like bundling some native macOS app which handles this part for you, or fixing the error above.
Any suggestions would be welcome! 🙂

Here is my setup:
MacOS 13.4
Electron 24.3.0
bundle.id registered to apple developer portal with push notifications, development provisioning profile downloaded, with developer certificate and push certificate. I have tested a SwiftUi native app with these files and NSApplication.shared.registerForRemoteNotifications() works.

forge.config.js

module.exports = {
  packagerConfig: {
    appBundleId: 'bundle.id',
    osxSign: {
      identity:'bundle.id',
      provisioningProfile: './profile.provisionprofile',
      entitlements: './test.entitlements'
    }
  },
  rebuildConfig: {},
  makers: [
    ...
    {
      name: '@electron-forge/maker-zip',
      platforms: ['darwin'],
    },
    ...
  ],
};

entitlements file:

...
<plist version="1.0">
<dict>
<key>com.apple.developer.aps-environment</key>
<string>development</string>
</dict>
</plist>

main.js (relevant lines, everything else is basically from the official docs)

app.whenReady().then(() => {
  createWindow()
  pushNotifications.registerForAPNSNotifications().then((token) => {
    console.log('SUCCESS', token);
  }).catch(e => { err = e; console.error(e) })
mighty grail
#

Facing similar issue