{"id":13462719,"url":"https://github.com/rakutentech/macos-push-tester","last_synced_at":"2025-05-01T12:38:59.813Z","repository":{"id":37421987,"uuid":"217222301","full_name":"rakutentech/macos-push-tester","owner":"rakutentech","description":"Native mac app for easily sending Apple APNs push notifications to iOS apps and FCM push notifications to Android apps.","archived":false,"fork":false,"pushed_at":"2023-07-28T06:44:34.000Z","size":3080,"stargazers_count":114,"open_issues_count":0,"forks_count":17,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-08-01T13:26:23.244Z","etag":null,"topics":["android","ios","macos","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rakutentech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-10-24T05:58:14.000Z","updated_at":"2024-07-26T06:06:10.000Z","dependencies_parsed_at":"2024-01-16T05:11:15.812Z","dependency_job_id":"c44ee394-6ba5-422d-8097-a1752b6dfcf3","html_url":"https://github.com/rakutentech/macos-push-tester","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakutentech%2Fmacos-push-tester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakutentech%2Fmacos-push-tester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakutentech%2Fmacos-push-tester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakutentech%2Fmacos-push-tester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rakutentech","download_url":"https://codeload.github.com/rakutentech/macos-push-tester/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245407543,"owners_count":20610227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ios","macos","swift"],"created_at":"2024-07-31T13:00:19.526Z","updated_at":"2025-03-25T05:32:11.803Z","avatar_url":"https://github.com/rakutentech.png","language":"Swift","funding_links":[],"categories":["Swift","push-tester"],"sub_categories":[],"readme":"![Platform](https://img.shields.io/badge/Platform-macOS-black) \n![Compatibility](https://img.shields.io/badge/Compatibility-macOS%20%3E%3D%2010.13-orange) \n![Compatibility](https://img.shields.io/badge/Swift-5.0-orange.svg) \n![License](https://img.shields.io/badge/License-MIT-lightgrey.svg) \n![Build Status](https://app.bitrise.io/app/120aff9438a0a19e.svg?token=fX7evo54lwDdFSg5xQfkWg\u0026branch=master)\n\n# The macOS Push Tester App\n\nThe macOS Push Tester App allows you to send push notifications through APNS (Apple Push Notification Service) or FCM (Firebase Cloud Messaging) and receive them on a device or simulator/emulator.\n\nThe macOS Push Tester App can also send push notifications to Live Activities on iOS devices (iOS \u003e= 16.1). This feature only works with APNS token.\n\nAndroid emulators must enable the Google API for Google Play services.\n\nIt can also get device tokens from any iPhone on the same wifi network.\n\n**Notice**: This app was created to be used by the Rakuten SDK team internally. Anyone is free to use it but please be aware that it is unsupported.\n\n## How to build/run from source\n\n- 1) Run `pod install` from root folder\n- 2) Open pusher.xcworkspace*\n- 3) Build and run\n\n## How to build with Fastlane\n\n### Install fastlane\n- 1) Using RubyGems `sudo gem install fastlane -NV` (or simply `bundle install`)\n\n- 2) Alternatively using Homebrew `brew cask install fastlane`\n\n### Run fastlane\nRun `fastlane ci`\n\n## Make your iOS app discoverable by the macOS Push Tester App\n\n- 1) Add this class to your iOS app\n\n```swift\nimport Foundation\nimport MultipeerConnectivity\n\n/// A device token can be generated from APNS or ActivityKit.\npublic enum DeviceTokenType: String {\n    case apns = \"APNS\"\n    case activityKit = \"ActivityKit\"\n}\n\npublic final class DeviceAdvertiser: NSObject {\n    private var nearbyServiceAdvertiser: MCNearbyServiceAdvertiser?\n    private let serviceType: String\n\n    private enum Keys {\n        static let deviceToken = \"token\"\n        static let applicationIdentifier = \"appID\"\n        static let deviceTokenType = \"type\"\n    }\n    \n    public init(serviceType: String) {\n        self.serviceType = serviceType\n        super.init()\n    }\n\n    /// Start advertising peer with device token (token), app identifier (appID) and device token type (type).\n    ///\n    /// - Parameters:\n    ///    - deviceToken: The APNS or ActivityKit device token\n    ///    - type: the device token type (APNS or ActivityKit)\n    public func setDeviceToken(_ deviceToken: String,\n                               type: DeviceTokenType = .apns) {\n        if let advertiser = nearbyServiceAdvertiser {\n            advertiser.stopAdvertisingPeer()\n        }\n\n        let peerID = MCPeerID(displayName: UIDevice.current.name)\n        \n        nearbyServiceAdvertiser = MCNearbyServiceAdvertiser(\n            peer: peerID,\n            discoveryInfo: [Keys.deviceToken: deviceToken,\n                            Keys.applicationIdentifier: Bundle.main.bundleIdentifier ?? \"\",\n                            Keys.deviceTokenType: type.rawValue],\n            serviceType: serviceType\n        )\n        \n        nearbyServiceAdvertiser?.delegate = self\n        nearbyServiceAdvertiser?.startAdvertisingPeer()\n    }\n}\n\nextension DeviceAdvertiser: MCNearbyServiceAdvertiserDelegate {\n    public func advertiser(_ advertiser: MCNearbyServiceAdvertiser,\n                           didReceiveInvitationFromPeer peerID: MCPeerID,\n                           withContext context: Data?,\n                           invitationHandler: @escaping (Bool, MCSession?) -\u003e Void) {\n        invitationHandler(false, MCSession())\n    }\n    \n    public func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didNotStartAdvertisingPeer error: Error) {\n    }\n}\n```\n- 2) Instantiate `DeviceAdvertiser`\n\n```swift\nlet deviceAdvertiser = DeviceAdvertiser(serviceType: \"pusher\")\n```\n\n- 3) Set the device token\n\n```swift\nfunc application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\n    deviceAdvertiser.setDeviceToken(deviceToken.hexadecimal)\n}\n```\n\n- 4) Add this `Data` extension to convert deviceToken to `String`\n\n```swift\nimport Foundation\n\nextension Data {\n    var hexadecimal: String {\n        map { String(format: \"%02x\", $0) }.joined()\n    }\n}\n```\n\n- 5) Add the following to your targets info.plist (required for iOS 14 and above)\n\n```xml\n\u003ckey\u003eNSBonjourServices\u003c/key\u003e\n\u003carray\u003e\n\t\u003cstring\u003e_pusher._tcp\u003c/string\u003e\n\t\u003cstring\u003e_pusher._udp\u003c/string\u003e\n\u003c/array\u003e\n\u003ckey\u003eNSLocalNetworkUsageDescription\u003c/key\u003e\n\u003cstring\u003eTo allow Pusher App to discover this device on the network.\u003c/string\u003e\n```\n\n## UI Preview\n\n![Send push notification to iOS device](preview-push-ios-device.png)\n![Send push notification to iOS simulator](preview-push-ios-simulator.png)\n![Send push notification to Android device](preview-push-android-device.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakutentech%2Fmacos-push-tester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frakutentech%2Fmacos-push-tester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakutentech%2Fmacos-push-tester/lists"}