OS X app for sending push with Apple Push Notification service (APNs)

Overview

pushHandle

OS X app for sending push with Apple Push Notification service (APNs)

Swift ICONKit-license type

About

This app was created just to allow painless testing of push notifications.

This app is in progress and for now have just a minimal implementation for testing with p8 key

screenshot

The work in progress...

Features

[x] sandbox/production mode

[x] customizable payload

[x] report errors and steps done under the hood

[x] .p8 support

[ ] payload syntax check

[ ] .p12 support

[ ] export request to curl

[ ] session store (for later reuse)

Small guide

get device apns token

Configre apple developer account:

  • generate certificate sing request on mac (Keychain->File->Request certificate sign identity)

  • Log in to Apple's Dev Center
  • Go to the Provisioning Portal or Certificates, Identifiers & Profiles
  • Create app identifier
  • Add certificate for push (sandbox and/or production)
  • Create p8 Key at Apple's Dev Center to use the app

In the project u need to allow required capabilities:

Then in u'r project App:

assuming u use SwiftUI

  1. declare UIApplicationDelegateAdaptor
@main
struct AuthentificatorApp: App {

  @UIApplicationDelegateAdaptor
  private var appDelegate: AppDelegate
  
  ....
  1. handle callbacks
final class AppDelegate: NSObject, UIApplicationDelegate {

  private let pushHandle: PushTokenHandle = .init()

  func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
  ) -> Bool {
    pushHandle.performStartConfig()
    pushHandle.handleIfAppOpenedWithNotificationInfo(launchOptions: launchOptions)

    return true
  }

  func application(
    _ application: UIApplication,
    didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
  ) {
    pushHandle.subscribeUsing(pushToken: deviceToken)
  }

  func application(
    _ application: UIApplication,
    didFailToRegisterForRemoteNotificationsWithError error: Error
  ) {
  // handle error
  }
}

implemntation of PushHandle:

final public class PushTokenHandle: NSObject {

  func performStartConfig() {
    UNUserNotificationCenter.current().delegate = self
  }

  func subscribeUsing(pushToken: Data) {
    let deviceToken = pushToken.hexString
  }
}

extension PushTokenHandle: UNUserNotificationCenterDelegate {
  public func userNotificationCenter(
    _ center: UNUserNotificationCenter,
    willPresent notification: UNNotification,
    withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions
    ) -> Void) {
    let userInfo = notification.request.content.userInfo
    completionHandler([.banner, .badge, .sound])
  }

  public func userNotificationCenter(
    _ center: UNUserNotificationCenter,
    didReceive response: UNNotificationResponse,
    withCompletionHandler completionHandler: @escaping () -> Void
  ) {
    let userInfo = response.notification.request.content.userInfo

    handlePushTap(userInfo)
    completionHandler()
  }
}

extension PushTokenHandle {

  func handleIfAppOpenedWithNotificationInfo(launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
    if let remotePushObject = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] {
      // parse object and send
    }
  }

  func handlePushTap(_ response: [AnyHashable: Any]) {
    let application = UIApplication.shared
    if application.applicationState == .active {
      debugPrint("user tapped the notification bar when the app is in foreground")
    }

    if application.applicationState == .inactive {
      debugPrint("user tapped the notification bar when the app is in background")
    }
  }
}
  1. convert data to tokenString:
public extension Data {

  var hexString: String {
    let parts = self.map { data in String(format: "%02.2hhx", data) }
    let value = parts.joined()
    return value
  }
}

More info about APNS here and here

License

MIT licensed.

Thanks to

Contact

Have a question or an issue about PushHandle? Create an issue!

If you would like to contribute - just create a pull request.

You might also like...
ToDoAppCoreData - MVVM + Core Data + Local Notification
ToDoAppCoreData - MVVM + Core Data + Local Notification

ToDo App Features MVVM + Core Data + Local Notification Screen recordings Creadi

FNotify - Notification Library For iOS

FNotify Notification Library For IOS FNotify.mov Requirements: xcode 12+ swift 5

Add the 'Hide Notification Badges' Focus mode setting from iOS to macOS
Add the 'Hide Notification Badges' Focus mode setting from iOS to macOS

FocusPlsNoBadges Add the 'Hide Notification Badges' Focus mode setting from iOS to macOS, in a really gross and hacky way. Getting started Build the X

Chanify is a safe and simple notification tools. This repository is iOS clinet for Chanify.
Chanify is a safe and simple notification tools. This repository is iOS clinet for Chanify.

Chanify English | 简体中文 Chanify is a safe and simple notification tools. For developers, system administrators, and everyone can push notifications wit

SNPnotificationBar - Notification Bar for ios
SNPnotificationBar - Notification Bar for ios

SNPnotificationBar Screenshot Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements S

Push notifications allow developers to reach users, even when users aren't actively using an app!
Push notifications allow developers to reach users, even when users aren't actively using an app!

Push notifications allow developers to reach users, even when users aren't actively using an app! With the latest update of iOS Apple provide very useful extensions which are user-friendly. In this tutorial, I am going to share the configuration, set up of Notification with the media attachments like.

Facebook Analytics In-App Notifications Framework
Facebook Analytics In-App Notifications Framework

Facebook In-App Notifications enables you to create rich and customizable in-app notifications and deliver them via push notifications, based on the a

Custom in-app notifications.
Custom in-app notifications.

CRNotifications CRNotifications are custom in-app notifications with 3 types of layouts. The notifications will animate in and out. They will hide whe

The debug application for Apple Push Notification Service (APNs).
The debug application for Apple Push Notification Service (APNs).

Knuff The debug application for Apple Push Notification Service (APNs). Download the latest version Features Send push notifications to APNS (Apple Pu

OS X and iOS application and framework to play with the Apple Push Notification service (APNs)
OS X and iOS application and framework to play with the Apple Push Notification service (APNs)

Pusher OS X and iOS application and framework to play with the Apple Push Notification service (APNs) Installation Install the Mac app using Homebrew

Swush - macOS Application to play with the Apple Push Notification service (APNs)
Swush - macOS Application to play with the Apple Push Notification service (APNs)

Swush ✨ Description A macOS app to push notifications to APNS with ease. ⚡ 💾 Pe

An example implementation of using a native iOS Notification Service Extension (to display images in remote push notification) in Titanium.

Titanium iOS Notification Service Extension An example implementation of using a native iOS Notification Service Extension (to display images in remot

🤨 Apple Push Notification service tutorial
🤨 Apple Push Notification service tutorial

APNsTutorial-iOS 🤨 Apple Push Notification service tutorial 단순히 순서를 따라서 가면 될 줄 알았는데 알아야할 것도 있었고 경우에 따라서 요구하는 파일도 달랐다. 그러니 천천히 읽어주시기 바랍니다. 먼저 어떤 서버 환경

APNSUtil is makes code simple using apple push notification service

APNSUtil APNSUtil makes code simple settings and landing for apple push notification service. Features Using apple push notification service simply No

Apple Push Notifications (APNs) Server-Side library.
Apple Push Notifications (APNs) Server-Side library.

Perfect-Notifications 简体中文 APNs remote Notifications for Perfect. This package adds push notification support to your server. Send notifications to iO

Apple Push Notifications (APNs) Server-Side library.
Apple Push Notifications (APNs) Server-Side library.

Perfect-Notifications 简体中文 APNs remote Notifications for Perfect. This package adds push notification support to your server. Send notifications to iO

Pushkin is a free open source tool for sending push notifications
Pushkin is a free open source tool for sending push notifications

Unmaintained This repository is no longer maintained. Pushkin Introduction Pushkin is a free open source tool for sending push notifications. It was d

CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service.
CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service.

CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service. He

PushDispatcher-vapor - Simple Api to dispatch push to APNS with p8 file

PushDispatcher - Vapor The purpose of this application is to facilitate the test

Releases(v.1.0.2)
  • v.1.0.2(Sep 11, 2022)

  • v.1.0.1(Sep 1, 2022)

    Initial release of fully-functional app

    • completely redesigned app with Swift/SwiftUI
    • include a tons of functionality:
      • [x] Auth with p8 key
      • [x] Auth with p12 cert
      • [x] Auth with keychain
      • [x] Custom push paylod
      • [x] Payload JSON validation
      • [x] Predefined payloads
      • [x] Full customization of push
      • [x] Build in hints
      • [x] Multiply sessions
      • [x] Session persistants
      • [x] History with detailed info
      • [x] Inspection of request with option to use curl for p8 auth
      • [x] Rich failure description
      • [x] Light/Dark mode
      • [x] Written in Swift
    Source code(tar.gz)
    Source code(zip)
    Antumbra.dmg(7.97 MB)
    demo.mp4(4.52 MB)
  • 0.0.1(Nov 7, 2021)

    Initial release with minimal implementation for push testing with .p8

    Full Changelog: https://github.com/khorbushko/pushHandle/commits/0.0.1

    Source code(tar.gz)
    Source code(zip)
Owner
hbk3
hbk3
OS X and iOS application and framework to play with the Apple Push Notification service (APNs)

Pusher OS X and iOS application and framework to play with the Apple Push Notification service (APNs) Installation Install the Mac app using Homebrew

noodlewerk 6.2k Dec 22, 2022
🤨 Apple Push Notification service tutorial

APNsTutorial-iOS ?? Apple Push Notification service tutorial 단순히 순서를 따라서 가면 될 줄 알았는데 알아야할 것도 있었고 경우에 따라서 요구하는 파일도 달랐다. 그러니 천천히 읽어주시기 바랍니다. 먼저 어떤 서버 환경

Hyungyu Kim 11 Dec 28, 2022
APNSUtil is makes code simple using apple push notification service

APNSUtil APNSUtil makes code simple settings and landing for apple push notification service. Features Using apple push notification service simply No

Steve Kim 30 Mar 24, 2022
Pushkin is a free open source tool for sending push notifications

Unmaintained This repository is no longer maintained. Pushkin Introduction Pushkin is a free open source tool for sending push notifications. It was d

Nordeus 257 Nov 3, 2022
How to Add Local Push Notification With timeInterval & Test On Simulator

Technicalisto How to Add Local Push Notification With timeInterval & Test On Simulator In Project Target ( Signing & Capapilities ) Add Capapility : 1

Aya Baghdadi 0 Jun 24, 2022
Push Notification Registration for iOS

Orbiter Note: This project is no longer being maintained. For most iOS client / server applications, push notifications are negotiated through an inte

Mattt 672 Nov 17, 2022
A Swift Library for Dynamic Island Push Notification.

Push Notification With Dynamic Island Handle Push Notification with Dynamic Island ?? Descreption: Since there is not library for Apple Push Notificat

Amir Diafi 5 Nov 12, 2022
SystemNotification is lets you mimic the native iOS system notification in your SwiftUI apps.

SystemNotification is a SwiftUI library that lets you mimic the native iOS system notification in your iOS apps.

Daniel Saidi 153 Dec 22, 2022
Custom notification view

Custom notification view

Ivan Kopiev 2 Sep 15, 2022
Roar - Let's reskin Notification Center

Roar Let's reskin Notification Center. See this blog post. Thanks Big thanks to

Tyler Hall 8 Mar 15, 2022