2017-12-05 1 views
0

로컬 데이터베이스를 사용할 때 null 인 gcm 등록 ID가 나타납니다. 내 로컬 컴퓨터의 서블릿과 함께이 버전의 코드바 앱을 실행합니다. 내 응용 프로그램은 플레이 스토어에 있고 장치 ID를 얻을 수 있다는 의미로 장치에서 제대로 작동하고있었습니다. 그러나 로컬 컴퓨터에서 서블릿을 사용하면 gcm 등록 ID가 null이라고 표시됩니다. 나는 구글이 스토어와 로컬 데이터베이스를 가지고 gcm 등록 id를 어떻게 생성하는지 혼란 스럽다.GCM 등록 ID가 null

답변

0

등록 ID를 얻기 위해 firebase에 대한 호출이 누락되었습니다. 나는 그것을 넣은 후에 등록 ID를 얻었습니다.

var push = PushNotification.init({ 
     "android": { 
      "senderID": 
     }, 
     "ios": { 
     "sound": true, 
     "alert": true, 
     "badge": true 
     }, 
     "windows": {} 
    }); 

push.on('registration', function(data) { 
     console.log("registration event: " + data.registrationId); 
     localStorage.setItem('registrationId', data.registrationId); 
    }); 

push.on('error', function(e) { 
     console.log("push error = " + e.message); 
    }); 

push.on('notification', function(data) { 
     console.log('notification event'); 
     navigator.notification.alert(
      data.message,   // message 
      null,     // callback 
      data.title,   // title 
      'Ok'     // buttonName 
     ); 

push.finish(function() { 
      console.log('success'); 
     }, function() { 
      console.log('error'); 
     }); 
    });