无法在收到通知后收到推送通知

时间:2020-09-27 04:40:20

标签: java android firebase push-notification firebase-cloud-messaging

我从FCM Cloud发送了一些测试推送通知,完美地传达了它的工作效果,我从FCM收到了5条以上的消息。但是之后,我什么也没收到来自FCM云消息。云消息状态显示为“ 已完成”,但没有任何内容可显示到android真实设备中。

这是我的MyfirebaseInstanceIdService

public class MyfirebaseInstanceIdService extends FirebaseMessagingService {
public MyfirebaseInstanceIdService() {
}
@Override
public void onNewToken(String token) {
    Log.d("Fcm Token", "Refreshed token: " + token);
    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
    sendRegistrationToServer(token);
}
private void sendRegistrationToServer(String token) {
}
}

这是MyService

public class MyService extends FirebaseMessagingService {
public MyService() {
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    String key = remoteMessage.getData().get("Key");
    Intent intent = new Intent(this,ReadingRoomTopicActivity.class);
    intent.setData(Uri.parse(key));
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pi = PendingIntent.
            getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
    String Channel_Id = "Default";
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this,Channel_Id);
    builder.setSmallIcon(R.drawable.ic_launcher_background)
            .setContentTitle(remoteMessage.getNotification().getTitle())
            .setContentText(remoteMessage.getNotification().getBody())
            .setAutoCancel(true)
            .setContentIntent(pi);
    NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
    {
        NotificationChannel channel = new NotificationChannel(Channel_Id,"Default channel",NotificationManager.IMPORTANCE_DEFAULT);
        manager.createNotificationChannel(channel);
    }
    manager.notify(0,builder.build());
}
}

这是我的清单

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dz.teacher.droodz">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.CAMERA" />

<supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />

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

    <service
        android:name=".MyfirebaseInstanceIdService"
        android:enabled="true"
        android:exported="true"></service>


    <service
        android:name=".MyService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>


    <activity
        android:name=".SplashActivity"
        android:theme="@style/AppCompat.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".ReadingRoomPostImageActivity" />
    <activity android:name=".MovieReiviewPosstActivity" />
    <activity android:name=".MyVideoVideoActivity" />
    <activity android:name=".MyVideoMainActivity" />
    <activity android:name=".ReadingRoomPostActivity" />
    <activity android:name=".Firestore1Activity" />
    <activity android:name=".VayanashalaUploadActivity" />
    <activity android:name=".MoviesTrailerWebActivity" />
    <activity android:name=".TrailerCategory3Activity" />
    <activity android:name=".TrailerCategory2Activity" />
    <activity android:name=".TrailerCategoryMainActivity" />
    <activity android:name=".MoviesQuizAnswerActivity" />
    <activity android:name=".MoviesQuiz1Activity" />
    <activity android:name=".JokeCategory3Activity" />
    <activity android:name=".JokeCategory2Activity" />
    <activity android:name=".JokeCategoryActivity" />
    <activity android:name=".PSCVideo5Activity" />
    <activity android:name=".YourVideoVideoActivity" />
    <activity android:name=".YourVideoActivity" />
    <activity android:name=".YourTravelVideoUploadActivity" />
    <activity android:name=".YourNewsVideoUploadActivity" />
    <activity android:name=".YourNewsVideo2Activity" />
    <activity android:name=".YourTravelVideo2Activity" />
    <activity android:name=".YourTecVideoUploadActivity" />
    <activity android:name=".YourVideoUploadActivity" />
    <activity android:name=".YourTecVideo2Activity" />
    <activity android:name=".YoursportsVideoUploadActivity" />
    <activity android:name=".YoursportsVideo2Activity" />
    <activity android:name=".YourFunVideoUploadActivity" />
    <activity android:name=".YourFunVideo2Activity" />
    <activity android:name=".YourFoodVideoUploadActivity" />
    <activity android:name=".YourFoodVideo2Activity" />
    <activity android:name=".YourFilmReview2Activity" />
    <activity android:name=".YourFilmReviewUploadActivity" />
    <activity android:name=".YourWebSeries2Activity" />
    <activity android:name=".MoviesCountry2Activity" />
    <activity android:name=".MoviesCountry1MainActivity" />
    <activity android:name=".YourWebSeriesUploadActivity" />
    <activity android:name=".YourShortFilmsUploadActivity" />
    <activity android:name=".YourShortFilms2Activity" />
    <activity android:name=".YourNewsVideoActivity" />
    <activity android:name=".YourTravelVideoActivity" />
    <activity android:name=".YoursportsVideoActivity" />
    <activity android:name=".YourTecVideoActivity" />
    <activity android:name=".YourFoodVideoActivity" />
    <activity android:name=".YourFunVideoActivity" />
    <activity android:name=".YourFilmReviewActivity" />
    <activity android:name=".YourWebSeriesActivity" />
    <activity android:name=".YourShortFilmsActivity" />
    <activity android:name=".WebWebActivity" />
    <activity android:name=".Web2Activity" />
    <activity android:name=".WebMainActivity" />
    <activity android:name=".ComputerVideoWebActivity" />
    <activity android:name=".PSCVyekthikalCategory2Mainactivity" />
    <activity android:name=".PSCVyekthikalCategoryMainactivity" />
    <activity android:name=".MoviesTelegramActivity" />
    <activity android:name=".PSCVyekthikal2Activity" />
    <activity android:name=".PSCVyekthikalMainActivity" />
    <activity android:name=".PSCAswamedham2Activity" />
    <activity android:name=".PSCAswamedhamMainActivity" />
    <activity android:name=".PSCCUrrentAffairsMonthsIActivity" />
    <activity android:name=".PSCCurrentAffairsActivity" />
    <activity android:name=".PSCCurrentAffairesDateIIIActivity" />
    <activity android:name=".PSCCurentAffairsMonthsII" />
    <activity android:name=".PSCCurentAffairsDateActivityII" />
    <activity android:name=".Story3Activity" />
    <activity android:name=".Story2Activity" />
    <activity android:name=".StoryMainActivity" />
    <activity android:name=".PSCYear2Activity" />
    <activity android:name=".PSCYearMainActivity" />
    <activity android:name=".DroodzMoviesSuggestions2PosterActivity" />
    <activity android:name=".MoviesCategory1Activity" />
    <activity android:name=".DroodzMoviesSuggessionWebSeries1Activity" />
    <activity android:name=".DroodzMoviesSuggestions3VideoActivity" />
    <activity android:name=".DroodzMoviesSuggestions1MainActivity" />
    <activity android:name=".DroodzMoviesTrailer3VideoActivity" />
    <activity android:name=".DroodzMoviesTrailer2PosterActivtiy" />
    <activity android:name=".DroodzMoviesReviewDetailActivity" />
    <activity android:name=".DroodzMoviesReview1Activity" />
    <activity android:name=".JokesDetailActivity" />
    <activity android:name=".KaleidoscopeDetailsActivity" />
    <activity android:name=".VideoFirebaseActivity" />
    <activity android:name=".JokesActivity" />
    <activity android:name=".KaledoscopeTopicActivity" />
    <activity android:name=".MoviesMainActivity" />
    <activity
        android:name=".ReadingRoomTopicActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".ReadingRoomDetailsActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".AswamedhamTopicActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".AswamedhamDetailsActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCGKTopicActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCGKDetailsActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".MovieReviewTopicActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".MovieReviewDetailsActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".LanguageAlphabet3Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".Language1Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".Language5Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".Language4Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".Language3Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".Language1MenuActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".Language2Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCTextbook4Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCTextbook3Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCTextbook2Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCTextbook1Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".ClassRoomNote2Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".ClassRoomNote1Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCPreviousQuestinPaper4Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCPreviousQuestinPaper3Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCPreviousQuestinPaper2Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCPreviousQuestinPaper1Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCClassRoom4Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCClassRoom3Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCClassRoom2Activity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCTrollDetailActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".TrollDetailActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCTrollActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".TrollActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCVideo4CategorySubjectActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCVideo3CategoryActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".QuizSecondSetStartActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".QuizSecondResultActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".QuizSecondSetActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCQuestinBankSubActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCAudioAcitivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCVideoActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCQuestinBankActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCMainActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".QuizStartActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".QuizResultActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".QuizandFactsActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity android:name=".NotificationsActivity" />
    <activity
        android:name=".UpcomingActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".VaayanashalaDetailActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".VaayanashalaManiActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".computerSubActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".computerTopicActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".EnterPageActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".AboutDroodz"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PricacyPolicy"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCVideo2VideoActivity"
        android:theme="@style/AppCompat.NoActionBar" />
    <activity
        android:name=".PSCVideo1Activity"
        android:theme="@style/AppCompat.NoActionBar" />

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-8867939169855032~9998384849" />
</application>

0 个答案:

没有答案