Giter Site home page Giter Site logo

gmshmspushionic's Introduction

Push kit HMS+ GMS example guide

AppGallery Connect Configuration

Please follow the instructions to enable push on the project and your AppGallery Connect console (Also you will need to enable push notification on firebase). Then add agconnect-services.json to root directory instructions.

Plugins

For this project, you will need to use the following plugins for Cordova.

-CordovaHMSGMSCheckPlugin: Check if HMS or GMS is avalaible on the phone.

-cordova-plugin-hms-push-4.0.3: Huawei Push kit pluging.

-FCM: Firebase plugin

-HTTP: Http requests plugin

Install the android platform

ionic cordova platform add android

Install the plugins using the following command

ionic cordova plugin add CORDOVA_PLUGIN_PATH

Modify the following files with your credentials.

gms-service.service.ts : Replace the API_KEY_SERVER_PUSH with yours given by Firebase

...
const API_KEY_SERVER_PUSH="<Replace-with-your-server-key>";
const API_PUSH_SEND = "https://fcm.googleapis.com/fcm/send";

hms-service.service.ts: replace the credentials with the ones given by the App gallery connect on your App.

...
const postData = {
      method: 'post',
      data: {
        //client secret and client id extracted from AppGallery console
        grant_type: "client_credentials",
        client_secret: '<your client secret>',
        client_id: '<your client id>'
      },
      headers: { 'content-type': 'application/x-www-form-urlencoded' }

    }
...

Change the path over the API_PUSH_SEND to include your App id in the URL.

const API_TOKEN = "https://oauth-login.cloud.huawei.com/oauth2/v2/token";
const API_PUSH_SEND = "https://push-api.cloud.huawei.com/v1/<your_app_id>/messages:send";

Run the project:

ionic cordova build android
ionic cordova run android

gmshmspushionic's People

Contributors

juangaines avatar

Watchers

Juan Gaines 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.