GithubHelp home page GithubHelp logo

alvareztech / android-notifications Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 158 KB

Sample app that shows the different notification services.

Home Page: https://alvarez.tech

Java 100.00%
hms hms-pushkit hms-push hms-sample

android-notifications's Introduction

Android Notifications

Sample app that shows the different notification services.

HMS

Client

implementation 'com.huawei.hms:push:5.0.2.300'

Common errors

getToken failed, com.huawei.hms.common.ApiException: 907135702: certificate fingerprint empty

Solution: Add fingerprint to Huawei web console.

HMSSDK_HmsInstanceIdEx: TokenTask failed, ErrorCode: 800100000
 getToken failed, com.huawei.hms.common.ApiException: 907122036: no right

Solution: Update agconnect-services.json configuration file.

Server

Get Token

Request
POST https://oauth-login.cloud.huawei.com/oauth2/v3/token
Host: oauth-login.cloud.huawei.com
Content-Type: application/x-www-form-urlencoded
  • grant_type: client_credentials
  • client_secret: Your Client Secret
  • client_id: Your Client ID
Response
{
    "access_token": "CgB6e3x9pzAkPR...",
    "expires_in": 3600,
    "token_type": "Bearer"
}

Send Message

Request
POST https://push-api.cloud.huawei.com/v1/[appid]/messages:send
Authorization: Bearer CgB6e3x9pzAkPRPDoctuJ...
{
    "validate_only": false,
    "message": {
        "notification": {
            "title": "Title 1",
            "body": "Body 1"
        },
        "android": {
            "notification": {
                "title": "Android Title 1",
                "body": "Android Body 1",
                "click_action": {
                    "type": 1,
                    "intent": "#Intent;compo=com.rvr/.Activity;S.W=U;end"
                }
            }
        },
        "token": [
            "client_token_1",
            "client_token_2"
        ]
    }
}
Response
{
    "code": "80000000",
    "msg": "Success",
    "requestId": "160209653167346065000206"
}

Resources

android-notifications's People

Contributors

alvareztech avatar

Stargazers

 avatar

Watchers

 avatar  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.