0

다음은이 튜토리얼을 따릅니다. http://intown.biz/2014/04/11/android-notifications/ 노드/각도/phonegap/ionic 앱을 개발 중입니다. 노드 -gcm을 사용하여 알림을 보냅니다. 그러나 나는 tuto의 일부를 이해하는 데 어려움을 겪고있다. 코드, 안드로이드 응용 프로그램 코드의 마지막 부분에서는 볼 수노드/phonegap/ionic을 사용하는 Android 푸시 알림

registerID : function (id) { 
      //Insert code here to store the user's ID on your notification server. 
      //You'll probably have a web service (wrapped in an Angular service of course) set up for this. 
      //For example: 
      MyService.registerNotificationID(id).then(function(response){ 
       if (response.data.Result) { 
        console.info('NOTIFY Registration succeeded'); 
       } else { 
        console.error('NOTIFY Registration failed'); 
       } 
      }); 

그래서 내가 바로, 사용자의 ID를 얻을 것이다 (여기이면 MyService라고 함) 서비스를 코딩 할 필요가?

문제는 : 나는 모든 것을 이해하지 못한다. 어떤 ID인지는 모르겠다. 그것은 안드로이드 장치의 ID입니까?

답변

0

예. 등록 ID를 서버에 보내는 서비스를 작성해야합니다.

등록 ID는 Android 기기의 ID가 아닙니다. GCM이 기기의 애플리케이션 인스턴스에 할당하는 ID입니다. 서버는 해당 ID를 사용하여 특정 기기의 앱에 메시지를 보냅니다.

0

당신이/등록 - 장치의 서버에 POST 요청을 전송한다이

app.factory('registerId', ['$http',function($http){ 
return { 
    registerNotificationID: function(id){ 
     $http 
      .post(serverurl+'register-device',{id:id, platform:'android'})//TODO: Change it for Each Platform before building. 
      .success(function(res){ 
       console.log(res) 
      }) 
      .error(function(e){ 
       console.error(e.message) 
      }) 
     } 
     } 
} 

같은 서비스/공장을 사용할 수 있습니다/당신은 거기에서 처리 할 수 ​​있으며, 공장을 주입해야합니다/DI의 서비스