Some device dont's receive push notification

℡╲_俬逩灬. 提交于 2019-12-13 02:29:37

问题


I implemented GCM push notification with play services 8.4 and sending via php with high priority. In my Android 4.3 I receive the message, even if after a few minutes while a J5 Samsung with Android 5.1 can take several hours and sometimes is not even received. I followed the google implementation guidelines for the gcm. In diagnosing GCM for the J5 of the message tracking token it is indicated as received by GCM but nothing else. J5 on other applications (whatsapp) receive notifications even in standby but not mine. Now it is as I seek solutions. I tried through alarm to wake up the manager app to input this, I tried with all the mechanisms suggested by Google but nothing. I found the information about it of 'HeartBeat but I understood that only decreases the contact time (from 28 minutes to as many as you want in a mobile connection) of the device to the GCM but the situation would not change. I do not care if the message comes after one hour, but the important thing is to arrive before my death. Help!

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.customer.myapp"
android:installLocation="auto"
android:versionCode="20"
android:versionName="1.4.4" >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="23"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"  
/>

<permission android:name="com.customer.myapp.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="com.customer.myapp.permission.C2D_MESSAGE" />

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 
android:maxSdkVersion="23"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" 
android:maxSdkVersion="23"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/main_logo"
    android:label="@string/app_name"
    android:logo="@drawable/main_logo" >
    <activity
        android:name=".Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
 <!-- .GcmBroadcastReceiver, Aggiunto exported -->
    <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" />
            <category android:name="com.customer.myapp" />
        </intent-filter>
    </receiver>
    <service
        android:name=".MyGCMListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>
    <service
        android:name=".MyInstanceIDListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID"/>
        </intent-filter>
    </service>
    <receiver
        android:name=".Boot"
        android:enabled="true"
        android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </receiver>


    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity
        android:name=".FBActivity"
        android:label="@string/title_activity_fb"
        android:parentActivityName=".Main" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.customer.myapp.Main" />
    </activity>
    <activity
        android:name="com.facebook.LoginActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />

    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/app_id" />

    <provider
        android:name="com.facebook.NativeAppCallContentProvider"           
android:authorities="com.facebook.app.NativeAppCallContentProviderXXXXXXXXX"
        android:exported="true" />

    <receiver android:name=".FacebookBroadcastReceiver" >
        <intent-filter>
            <action   
android:name="com.facebook.platform.AppCallResultBroadcast" />
        </intent-filter>
    </receiver>

    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id" />

    <activity
        android:name=".WebviewAct"
        android:label="@string/title_activity_webview"
        android:parentActivityName=".Main" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.customer.myapp.Main" />
    </activity>
    <activity
        android:name=".ArgomentiActivity"
        android:label="@string/title_activity_argomenti"
        android:parentActivityName=".Main" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.customer.myapp.Main" />
    </activity>
    <activity
        android:name=".Luoghi"
        android:label="@string/title_activity_luoghi" >
    </activity>
    <activity
        android:name=".InfoActivity"
        android:label="@string/title_activity_info" >
    </activity>
    <service android:name=".RegistrationIntentService"     
android:exported="false"></service>
    <receiver android:process=":remote" android:name=".BroadcastFormyapp">   
</receiver>
    <receiver android:name=".AutoStart">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
    </receiver>
    <service
        android:name=".ServiceAlarm"
        android:enabled="true"
         >  <!-- android:process=":" -->   
    </service>       
    <service
        android:name=".GcmIntentService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
     </service>
</application>

</manifest>

Payload in PHP:

    $fields=array(
    "registration_ids"=>$registration_ids,
    "delay_while_idle" => true,
    "priority" => "high",
    "data"=>$message
);

来源:https://stackoverflow.com/questions/37044734/some-device-donts-receive-push-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!