2016-11-05 1 views
0

롤리팝 아래 안드로이드를 실행하는 기기에서 GCM 메시지를 수신 할 수 없습니다. 푸시 메시지에서 작동 안드로이드 5, 6, ... 내 응용 프로그램 코드가 왜 7 는 정말 모르겠어요은 롤리팝 아래에있는 gcm android 메시지를받을 수 없습니다.

매니페스트 :

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25"/> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<uses-permission android:name="android.permission.INTERNET" /> 

<permission android:name="sbntt.android.xenoss.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 
<uses-permission android:name="sbntt.android.xenoss.permission.C2D_MESSAGE" /> 

<application 
    android:name="android.support.multidex.MultiDexApplication" 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 

    <receiver 
     android:name="com.google.android.gms.gcm.GcmReceiver" 
     android:exported="true" 
     android:permission="com.google.android.c2dm.permission.SEND" > 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
      <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> 
      <category android:name="sbntt.android.xenoss" /> 
     </intent-filter> 
    </receiver> 
    <service 
     android:name="sbntt.android.xenoss.GCMPushReceiverService" 
     android:exported="false" > 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
     </intent-filter> 
    </service> 
    <service 
     android:name=".GCMRegistrationIntentService" 
     android:exported="false"> 
     <intent-filter> 
      <action android:name="com.google.android.gms.iid.InstanceID" /> 
     </intent-filter> 
    </service> 
    <service 
     android:name=".GCMTokenRefreshListenerService" 
     android:exported="false"> 
    </service> 

</application> 

GCMPushReceiverService 클래스

@Override 
public void onMessageReceived(String from, Bundle data) { 
    String message = data.getString("message"); 
    if (Settings.preference != null) { 
     if (Settings.preference.getBoolean("notifications", true)) { 
      sendNotification(message); 
     } 
    } else { 
     sendNotification(message); 
    } 
} 


private void sendNotification(String message) { 
    Intent intent = new Intent(this, MainActivity.class); 
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    int requestCode = 0; 
    PendingIntent pendingIntent = PendingIntent.getActivity(this, requestCode, intent, PendingIntent.FLAG_ONE_SHOT); 
    Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
    NotificationCompat.Builder noBuilder = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.ic_menu_youtube) 
      .setContentTitle("TITLE") 
      .setContentText(message) 
      .setAutoCancel(true) 
      .setContentIntent(pendingIntent) 
      .setSound(sound) 
      .setDefaults(Notification.DEFAULT_ALL) 
      .setPriority(Notification.PRIORITY_HIGH); 

    NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); 
    notificationManager.notify(0, noBuilder.build()); 
} 

등록이 정상적으로 작동합니다! 도움 주셔서 감사합니다.

답변

0

GCM을 업데이트해야합니다. 재생 서비스 프로젝트에서 Play Service를 업데이트하거나 적은 재생 서비스 버전을 사용하도록 사용자에게 알릴 수 있습니다.

+0

주요 활동에 대한 게임 서비스 체크가 있습니다. 기기가 실행중인 kitkat은 최신 Google Play 서비스 버전 – SBNTT

+0

입니다. 메시지에 adb 로그 메시지 재생 서비스 태그가 있습니까? –

+0

결정적인 부분에 재생 서비스 업데이트를 제거한 다음 다시 업데이트하면 작동합니다 ... 도와 주셔서 감사합니다 – SBNTT

관련 문제