2016-11-05 5 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サービスを更新するか、少ない再生サービスバージョンを使用するようにユーザーに通知できます。

+0

メインアクティビティのプレイサービスチェックがあります。デバイスは、kitkatを実行している最新のGoogleプレイサービスのバージョンを持っています – SBNTT

+0

あなたはどのようなメッセージを持っていますか? –

+0

デセルでプレイサービスアップデートをアンインストールしてから、もう一度アップデートしてください...あなたの助けをありがとう – SBNTT

関連する問題