Coder Social home page Coder Social logo

milankamilya / apns Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 95 KB

How to send push notification in iPhone, iPad ( iOS devices ) from APNS using App Key

License: GNU General Public License v3.0

JavaScript 87.11% Lua 4.31% CSS 2.47% Pug 6.11%
apns-p8 apnsserver nodejs ios push-notifications apns-certificate troubleshooting server-setup

apns's Introduction

Apple Push Notification Service ( APNS )

How to send push notification in iPhone, iPad ( iOS devices ) from APNS using App Key

Prerequisites

Hey Devs, hope you know about Push Notifications (PN) already. If you like to know please use this link how to setup push notification in your Apple Developer and how to incorporate it in your iOS Xcode project.

To send PN to iOS devices, we need a Certificate ( p12 ) or App Key ( p8 ). Using certificate comes liability of yearly maintenance. You need to update certificate each year as it expires. Using App Key is latest Procedure. How to generate App Key.

WARNING: Hope you saved App Key in a secure place because the key is not saved in your developer account and you won’t be able to download it again. If the Download button is disabled, you previously downloaded the key.

We will use nodejs as server. So, please check whether you have nodejs installed on your pc. To install nodejs follow this.

How Install

Now, we are ready to go. Download the project and run 'npm install' in terminal from project directory. Open the entire project in a Text Editor (i.e. VSCode, Sublime etc).

Place auth key in keys folder (i.e. AuthKey_XXXXXXXXXX.p8). Now, open you apns.js file. You need to change following.

  • Name of the AuthKey (i.e. './keys/AuthKey_XXXXXXXXXX.p8'
  • KeyID (i.e. 10 alphanumeric characters followed by 'AuthKey_' )
  • TeamID (i.e. 10 alphanumeric characters. you can find it in Xcode as well as in Apple Developer Account )

The setup is completed now.

To run the server, run 'npm start' in terminal from the project directory.

How to Send First Test Push Notification

We are using Postman for POST http call.

URL     : 'http://127.0.0.1:3000/apn'
Headers : Content-Type = application/json
Body    : {
	"deviceToken": "< collect & put push notification device token from real iOS one >"
}

Now, click on send.

CHEERS!!!, you got the first push notification.

If you face any issue, please create a issue in github. I will help you out

Troubleshooting APNS

Please check following link to troubleshoot various cases.

Author

Milan Kamilya, twitter, LinkedIn

apns's People

Contributors

dependabot[bot] avatar milankamilya avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.