Pushover API for sending push notifications to mobile phones: usage and sample code

Today I'm going to introduce a great tool that I've been using for over two years, but haven't had time to recommend to others: Pushover, a mobile push notification service API, including its usage, settings, and implementation.

use

Push notifications are placed at key points (such as user registration, reports, comments, system checks, etc.). When a point is triggered, it will send a push notification to your phone, allowing you to get the key information immediately (such as a server failure).

Usage Introduction

It's very easy to use. Once you've set it up on the pushover website, simply add the API to any node you want to push to.

accomplish

Let's consider a use case where I want to know immediately if a user has registered in the system. Here are the implementation steps:

  1. Register a Pushover account: https://pushover.net/
  2. After logging in, you will see your API key and secret. Save them for later use.
  3. In the My Application section at the bottom, select Create New.
  4. Enter the application name (anything easy to identify), select "plugin" for the type (please refer to the documentation for changes), write anything you like for the description, enter the address you are using for the URL, and upload a nice-looking icon (it will be displayed on your phone).
  5. After filling in the information, an API Token/Key will be generated. Save it for later use.

The online steps are now complete. The remaining step is deploying the code, which I won't go into detail about here. It simply involves downloading a library and storing the key. Please refer to the documentation: https://pushover.net/api#messages

Here's a PHP example.

 'https://api.pushover.net/1/messages.json', CURLOPT_POSTFIELDS => array( 'token' => 'Enter the key of your application here', 'user' => 'The userkey displayed after login', 'message' => 'This is the message', ), CURLOPT_SAFE_UPLOAD => true, )); curl_exec($ch); curl_close($ch); ?>

Isn't it easy? Just deploy the code to where you want, and you're done. The last step is to download the Pushover app from the App Store (I think it costs .99). However, once you buy it, you can transfer it anywhere with just one account. I bought it on both Google and Apple App Stores, and as long as you log in with the same account, you can download and receive push notifications.

You can also specify the accepted devices in the backend, but we won't go into details here.

Isn't it much easier than building your own push service? Let me end with a few pictures.

推送信息到手机的API——pushover使用方法及sample code - - Jake blog推送信息到手机的API——pushover使用方法及sample code - push iphone - Jake blog

This siteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)Please retain the following annotations when sharing or adapting:

Original author:Jake Tao,source:"Pushover API for Sending Push Notifications to Phones: Usage and Sample Code"

149
0 7 149

Post a reply

Log inYou can only comment after that.

Comment list (7 items)

  • [...] Simple mobile push notifications: PushOver (See instructions for use:https://blog.jing.do/2172)[…]

  • 志明
    Zhiming 2018-12-22 11:50

    Hello, I'm a complete beginner and have many questions I'd like to ask. Could we chat on WeChat? sange564813

  • 段
    2018-12-03 02:04

    Can you teach me?

    • 天堂的头像
      Heaven 2018-12-03 07:16

      @partWhat's causing your problem? What's the specific issue?

  • 匿名
    anonymous 2018-03-04 02:27

    Hi expert, I still don't understand many parts of your article. Do you take freelance work?

    • 天堂的头像
      Heaven 2018-03-04 12:02

      @anonymousThis is relatively easy to do. Try it out; feel free to ask me if you have any questions. I can outsource it.

    • 匿名
      anonymous 2019-10-19 03:04

      @Jake TaoHow to contact

Share this page
Back to top