相关疑难解决方法(0)

当应用程序从多任务托盘停止时,Android应用程序未收到Firebase通知

我在SO上读过类似的问题,然而,我无法从中得到正确的答案.

我有一个系统,我们向大约500个设备发送通知.

不幸的是,许多这些设备没有收到通知.我发现OPPO F1系列手机特别没有收到通知.

我发现,如果应用程序从多任务托盘中停止,则会发生这种情况.我该如何解决这个问题?

更新:我观察到当我从任务托盘关闭应用程序时,我的应用程序被强制停在应用程序管理器中.当我从任务托盘关闭Whatsapp时,仍然没有强制停止.怎么被Whatsapp处理?

android firebase firebase-cloud-messaging firebase-notifications

67
推荐指数
3
解决办法
4万
查看次数

错误广播意图回调:result = CANCELED forIntent {act = com.google.android.c2dm.intent.RECEIVE pkg = com.flagg327.guicomaipu(has extras)}

我从Android Studio的Android Monitor收到了这个错误.当我通过GCM在真实设备中发送推送通知并且应用尚未启动或已被迫停止时,会出现此错误.昨天一切正常,今天根本不起作用(仅当应用程序在后台或前台运行时才有效).

我认为这可能是一个AndroidManifest错误,但我厌倦了寻找问题而找不到任何东西.

表现

<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.flagg327.guicomaipu">

    ...

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

        ...

        <!--GOOGLE CLOUD MESSAGE-->
        <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="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <!-- for Gingerbread GSF backward compat -->
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.flagg327.guicomaipu" />
            </intent-filter>
        </receiver>

        <service
            android:name="com.flagg327.guicomaipu.gcm.RegistrationService"
            android:exported="false" />

        <service
            android:name="com.flagg327.guicomaipu.gcm.TokenRefreshListenerService"
        android:exported="false">
            <intent-filter>
                <action
                    android:name="com.google.android.gms.iid.InstanceID" />
            </intent-filter>
        </service>

        <service
            android:name="com.flagg327.guicomaipu.gcm.NotificacionsListenerService"
        android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>

    </aplication>

    <permission 
        android:name="com.flagg327.guicomaipu.C2D_MESSAGE"
            android:protectionLevel="signature" />
    <uses-permission android:name="com.flagg327.guicomaipu.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" …
Run Code Online (Sandbox Code Playgroud)

android push-notification google-cloud-messaging

23
推荐指数
5
解决办法
1万
查看次数

当Android应用程序从最近的托盘中删除时,Firebase(FCM)通知不会出现

我正在通过我自己的Web服务发送Firebase通知,如下所示.

$url = 'https://fcm.googleapis.com/fcm/send';
        $fields = array(
             'registration_ids' => $tokens,
             'data' => $message
            );
        $headers = array(
            'Authorization:key = SERVER_KEY ',
            'Content-Type: application/json'
            );
Run Code Online (Sandbox Code Playgroud)

1.当App在前台和后台没有任何问题时,通知即将到来,但如果我从最近的托盘中删除应用程序然后通知没有到来,我必须处理这个任何解决方案吗?(就像Whatsup通知显示所有场景甚至我强制停止此应用程序的设置)

2.一旦我收到通知,从"onMessageReceived"如何将这些消息,正文内容传递给我的Activity/Fragments?

3.在某些情况下,我想向所有人发送通知,而不是将所有令牌添加到数组中.任何其他方式处理像"发送给所有"这样的东西?

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    private static final String TAG = "MsgService";
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.d(TAG, "From: " + remoteMessage.getFrom());
        Log.d(TAG, "Data Payload : " + remoteMessage.getData());
        sendNotification(remoteMessage.getData().get("message"));
    }
    private void sendNotification(String messageBody) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
                PendingIntent.FLAG_ONE_SHOT);
        Uri …
Run Code Online (Sandbox Code Playgroud)

notifications android android-notifications firebase firebase-cloud-messaging

8
推荐指数
1
解决办法
5564
查看次数