All Projects → pisces → Apnsutil

pisces / Apnsutil

Licence: mit
APNSUtil is makes code simple using apple push notification service

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Apnsutil

Macproject
这是一个用 Objective-C 写的 iOS 轻量级框架,旨在快速构建 iOS App,欢迎 Star
Stars: ✭ 544 (+1654.84%)
Mutual labels:  utils
Utils
A collection of useful PHP functions, mini classes and snippets that you need and can use every day.
Stars: ✭ 750 (+2319.35%)
Mutual labels:  utils
Androidcommon
基于Android系统Api封装常用工具类
Stars: ✭ 870 (+2706.45%)
Mutual labels:  utils
Ramda Adjunct
Ramda Adjunct is the most popular and most comprehensive set of functional utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
Stars: ✭ 550 (+1674.19%)
Mutual labels:  utils
Netutils Linux
A suite of utilities simplilfying linux networking stack performance troubleshooting and tuning.
Stars: ✭ 664 (+2041.94%)
Mutual labels:  utils
Toot Relay
Relay that forwards web push notifications to APNs, built for Toot!.app but usable for anyone.
Stars: ✭ 18 (-41.94%)
Mutual labels:  apns
Airnotifier
Push Notifications Server for Human Beings.
Stars: ✭ 522 (+1583.87%)
Mutual labels:  apns
Dialogutil
common used dialog with material style ( in support v7),ios style,get top activity automatically, invoke everywhere (any thread , any window)
Stars: ✭ 948 (+2958.06%)
Mutual labels:  utils
Devutils
🔥 ( 持续更新,目前含 160+ 工具类 ) DevUtils 是一个 Android 工具库,主要根据不同功能模块,封装快捷使用的工具类及 API 方法调用。该项目尽可能的便于开发人员,快捷、高效开发安全可靠的项目。
Stars: ✭ 680 (+2093.55%)
Mutual labels:  utils
Lxd Functions
Simple script to mount LXD container and match host user with container user (uid/gid)
Stars: ✭ 11 (-64.52%)
Mutual labels:  utils
Java Study
java-study 是本人学习Java过程中记录的一些代码!从Java基础的数据类型、jdk1.8的Lambda、Stream和日期的使用、 IO流、数据集合、多线程使用、并发编程、23种设计模式示例代码、常用的工具类, 以及一些常用框架,netty、mina、springboot、kafka、storm、zookeeper、redis、elasticsearch、hbase、hive等等。
Stars: ✭ 571 (+1741.94%)
Mutual labels:  utils
Gorush
A push notification server written in Go (Golang).
Stars: ✭ 5,933 (+19038.71%)
Mutual labels:  apns
Myjdbc Rainbow
jpa--轻量级orm模式对象与数据库映射api
Stars: ✭ 23 (-25.81%)
Mutual labels:  utils
Emacs Elisp Programming
Tutorial about programming Elisp and Emacs text editor customization.
Stars: ✭ 548 (+1667.74%)
Mutual labels:  utils
Androidlibs
🔥正在成为史上最全分类 Android 开源大全~~~~(长期更新 Star 一下吧)
Stars: ✭ 7,148 (+22958.06%)
Mutual labels:  utils
Ethereumjs Util
Project is in active development and has been moved to the EthereumJS monorepo.
Stars: ✭ 534 (+1622.58%)
Mutual labels:  utils
Gaurun
General push notification server in Go
Stars: ✭ 804 (+2493.55%)
Mutual labels:  apns
Jwt
Kotlin JWT 🔑 implementation (Json Web Token) as required by APNs 🔔 (Apple Push Notifications) or Sign in with Apple 🍏
Stars: ✭ 31 (+0%)
Mutual labels:  apns
Androidutilcode
AndroidUtilCode 🔥 is a powerful & easy to use library for Android. This library encapsulates the functions that commonly used in Android development which have complete demo and unit test. By using it's encapsulated APIs, you can greatly improve the development efficiency. The program mainly consists of two modules which is utilcode, which is commonly used in development, and subutil which is rarely used in development, but the utils can be beneficial to simplify the main module. 🔥
Stars: ✭ 30,239 (+97445.16%)
Mutual labels:  utils
Mongodb Utils
MongoDB utils library for Node.js
Stars: ✭ 9 (-70.97%)
Mutual labels:  utils

APNSUtil

Swift CI Status Version License Platform Carthage Compatible

  • APNSUtil makes code simple settings and landing for apple push notification service.

Features

  • Using apple push notification service simply
  • No need write codes for any iOS versions
  • Support chained functional programing

Import

import APNSUtil

Using

Implementation for main view controller

import UIKit
import APNSUtil

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        APNSManager.shared
            .setTypes([.sound, .alert, .badge])             // setting user notification types
            .register()                                     // register to use apns
            .subscribe(self) {                             // subscribe to receive apns payload
                // your payload model with generic
                guard let payload: APNSPayload = $0.payload() else {
                    return
                }

                print("subscribe", $0.isInactive, $0.userInfo, payload)

                if $0.isInactive {
                    // TODO: write code to present viewController on inactive
                } else {
                    // TODO: write code to show toast message on active
                }
            }.begin()   // begin to receive apns payload
    }
}

Implementation for app delegate

import UIKit
import UserNotifications
import APNSUtil

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        APNSManager.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        return true
    }

    // MARK: - Push Notification

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        APNSManager.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
        // <<your function to register device token on your server>>(APNSInstance.shared.tokenString)
    }
    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    }

    // MARK: - Push Notification for iOS 9

    func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings) {
        APNSManager.shared.application(application, didRegister: notificationSettings)
    }
    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
        APNSManager.shared.application(application, didReceiveRemoteNotification: userInfo)
    }

    // MARK: - Public Methods (UIApplicationDelegate - Local Notification)

    func application(_ application: UIApplication, didReceive notification: UILocalNotification) {
        APNSManager.shared.application(application, didReceive: notification)
    }
}

extension AppDelegate: UNUserNotificationCenterDelegate {
    @available(iOS 10.0, *)
    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        APNSManager.shared.userNotificationCenter(center, willPresent: notification)
    }
    @available(iOS 10.0, *)
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        APNSManager.shared.userNotificationCenter(center, didReceive: response)
    }
}

Implement your payload model

struct APNSPayload: Decodable {
    let aps: APS?

    // Add properties here you need

    struct APS: Decodable {
        let sound: String?
        let alert: Alert?
    }

    struct Alert: Decodable {
        let body: String?
        let title: String?
    }
}

Using with your payload model as generic

  APNSManager.shared
      .setTypes([.sound, .alert, .badge])
      .register()
      .subscribe(self) {
          guard let payload: APNSPayload = $0.payload() else {
              return
          }

          // write here to process payload model
      }.begin()

Using with raw userInfo

  APNSManager.shared
      .setTypes([.sound, .alert, .badge])
      .register()
      .subscribe(self) {
          let userInfo = $0.userInfo

          // write here to process userInfo
      }.begin()

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.0.0+ is required to build APNSUtil 1.1.5+.

To integrate APNSUtil into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

# Default
target '<Your Target Name>' do
    pod 'APNSUtil', '~> 1.6.0'
end

# for AppExtension
target '<Your Target Name>' do
    pod 'APNSUtil/AppExtension', '~> 1.6.0'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Alamofire into your Xcode project using Carthage, specify it in your Cartfile:

github "pisces/APNSUtil" ~> 1.6.0

Run carthage update to build the framework and drag the built APNSUtil.framework into your Xcode project.

Requirements

iOS Deployment Target 9.0 higher

Author

Steve Kim, [email protected]

License

APNSUtil is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].