Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

firebase - step by step implementation of nativescript push notification in nativescript

can anyone give step by step guidence starting from creating a helloworld app then the remaining steps to do push notifications. i have already gone through the below link and failed to achieve that https://github.com/EddyVerbruggen/nativescript-plugin-firebase

i have some progress on it, refer below code.

http.request({
        url: 'https://fcm.googleapis.com/fcm/send',
        method: "POST",
        headers: { 'Authorization': 'key=AIzaSyBri16HAa7g2REEy******YFnTDGIlM_1k', 'Content-Type': 'application/json' },
        content: JSON.stringify({
          "notification": {
            "title": "testingtesting",
            "text": "some text",
            "sound": "default",
            "click_action": "GENERAL",
            "badge": "1",
            "showWhenInForeground": true
          },
          "content_available": false,
          "data": {
            "foo": "bar"
          },
          "priority": "High",
          'to': "AAAACcS8hG0:APA91bEonX87xRfBHvccNheOR2ppFHZKaFlGGm6PRF6eEEYZg5Gd7uU_OU0GRJ0MkiTrR2gSDGO7Nz6BByujX4ex1jGgKpO20SXcGMa78k405vNV_4uJ1UDk_b-0-regi5x96KRcaOMH"
        })
      }).then((response) => {
        //HttpResult = response.content.toJSON();
        console.log('----------------------------------------------------');
        console.log(response);
      }, (e) => {
        console.log("Error occurred " + JSON.stringify(e));
      });
    },

the response is as below.

JS: ----------------------------------------------------
JS: {
JS:   "content": {
JS:     "multicast_id": 5720873045813109000,
JS:     "success": 1,
JS:     "failure": 0,
JS:     "canonical_ids": 0,
JS:     "results": [
JS:       {
JS:         "message_id": "0:1548488437363910%0000000000000000"
JS:       }
JS:     ]
JS:   },
JS:   "statusCode": 200,
JS:   "headers": {
JS:     "null": "HTTP/1.1 200 OK",
JS:     "Alt-Svc": "quic=":443"; ma=2592000; v="44,43,39"",
JS:     "Cache-Control": "private, max-age=0",
JS:     "Content-Encoding": "gzip",
JS:     "Content-Type": "application/json; charset=UTF-8",
JS:     "Date": "Sat, 26 Jan 2019 07:40:37 GMT",
JS:     "Expires": "Sat, 26 Jan 2019 07:40:37 GMT",
JS:     "Server": "GSE",
JS:     "Transfer-Encoding": "chunked",
JS:     "X-Android-Received-Millis": "1548488436596",
JS:     "X-Android-Response-Source": "NETWORK 200",
JS:     "X-Android-Selected-Protocol": "http/1.1",
JS:     "X-Android-Sent-Millis": "1548488436437",
JS:     "X-Content-Type-Options": "nosniff",
JS:     "X-Frame-Options": "SAMEORIGIN",
JS:     "X-XSS-Protection": "1; mode=block"
JS:   }
JS: }

even it says success. i have not got any notification on android. i'm not using ios.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...