2014-06-16 3 views
2

저는 모바일 애플리케이션을 개발 중이며 푸시 알림을 받고 있습니다.푸시 알림, 토큰 만료?

나는 전화 (사과 또는 안드로이드)에서 토큰을 검색 용으로 보내기 푸시하지만 난 질문 할 수 있습니다 :

이 토큰은 항상 같은입니다? 한 번 토큰을 받으면 토큰이 바뀌는 지 확인해야합니까? 토큰 신뢰의이 단계의 형태

사과 문서에서

답변

2

,

에만있는 APN은 토큰이에서 나중에 명예를 생성 함을 보장하고, 그 자체를 보장 할 수있는하여 물려 토큰 장치는 해당 장치에 대해 이전에 제공된 과 동일한 토큰이며 해당 장치에 대해서만 제공됩니다.

사용자가 백업 데이터를 새 장치로 복원하거나 운영 체제를 다시 설치하면 장치 토큰이 변경됩니다.

그래서 APN에서받은 토큰으로 서버를 업데이트하는 것이 좋습니다. 최적화의 일부로 동일한 토큰을받는 경우 서버를 업데이트 할 필요가 없습니다.

안드로이드에 대한
+1

참고 : 견적의 마지막 문장이 삭제되었습니다. – macserv

1

:

그것은 구현에 따라 달라집니다,하지만 구글에서 권장하는 응용 프로그램이 업데이트 된 후 등록 ID가 변경 될 수 있다는 것입니다 ...

매번 등록 ID 클라이언트가 변경되면 서버는 새 값으로 서버를 업데이트해야합니다.

체크 [문서 (https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html)가 변경되었음을 http://developer.android.com/google/gcm/client.html#sample-register

if (checkPlayServices()) { 
     gcm = GoogleCloudMessaging.getInstance(this); 
     regid = getRegistrationId(context); 

     if (regid.isEmpty()) { 
      registerInBackground(); 
     } 
    } else { 
     Log.i(TAG, "No valid Google Play Services APK found."); 
    } 

private void registerInBackground() { 
new AsyncTask() { 
    @Override 
    protected String doInBackground(Void... params) { 
     String msg = ""; 
     try { 
      if (gcm == null) { 
       gcm = GoogleCloudMessaging.getInstance(context); 
      } 
      regid = gcm.register(SENDER_ID); 
      msg = "Device registered, registration ID=" + regid; 

      // You should send the registration ID to your server over HTTP, 
      // so it can use GCM/HTTP or CCS to send messages to your app. 
      // The request to your server should be authenticated if your app 
      // is using accounts. 
      sendRegistrationIdToBackend(); 

      // For this demo: we don't need to send it because the device 
      // will send upstream messages to a server that echo back the 
      // message using the 'from' address in the message. 

      // Persist the regID - no need to register again. 
      storeRegistrationId(context, regid); 
     } catch (IOException ex) { 
      msg = "Error :" + ex.getMessage(); 
      // If there is an error, don't just keep trying to register. 
      // Require the user to click a button again, or perform 
      // exponential back-off. 
     } 
     return msg; 
    } 

    @Override 
    protected void onPostExecute(String msg) { 
     mDisplay.append(msg + "\n"); 
    } 
}.execute(null, null, null); 
... 
}