5

starting on android P my app is not able to register for a GCM ID. My PushManager code looks like

try
        {
            GcmClient.CheckDevice(context);
            GcmClient.CheckManifest(context);
            String[] senderIds = GcmBroadcastReceiver.SENDER_IDS;
            foreach (String id in senderIds)
            {
                System.Diagnostics.Debug.WriteLine("sender id = " + id);
            }

            GcmClient.Register(context, senderIds);

            if (GcmClient.IsRegistered(context))
            {
                System.Diagnostics.Debug.WriteLine("push registration successfull: " +
                                                   GcmClient.GetRegistrationId(context));
            }
        }
        catch (Exception e)
        {
            System.Diagnostics.Debug.WriteLine("push registration failed: " + e.Message.ToString());
        }

My manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.app" android:versionName="1.8.5" android:versionCode="97">
    <uses-sdk android:minSdkVersion="16" />
    <application android:label="My app" android:icon="@mipmap/icon" android:theme="@style/Theme.App" android:hardwareAccelerated="true" android:windowSoftInputMode="stateHidden|adjustResize" android:name="android.support.multidex.MultiDexApplication">
        <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
    </application>
    <permission android:name="com.rotogrinders.rg_lineups.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.rotogrinders.rg_lineups.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <permission android:name="android.permission.STATUS_BAR_SERVICE" android:protectionLevel="signature" />
<!-- For Google Play Services -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    <action android:name="com.google.android.c2dm.intent.REGISTER" />
    <service android:name="com.google.android.gms.analytics.AnalyticsService" android:enabled="true" android:exported="false" />

Whenever I try to register or unregister i get this error:

07-05 16:35:49.156 W/ActivityManager( 1167): Unable to start service Intent { act=com.google.android.c2dm.intent.UNREGISTER pkg=com.google.android.gsf (has extras) } U=0: not found
07-05 16:35:49.169 W/ActivityManager( 1167): Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf (has extras) } U=0: not found

I've found that devices running older OSs register fine. the only issue I've had with this so far is with the android P preview. Any help would be appreciated.

  • Why are you using GCM? it is going to be taken out soon i would suggest you use FCM instead – FreakyAli Jul 06 '18 at 06:02
  • 1
    Switching to FCM is on my to do list. I was thinking about just ignoring this issue and hoping FCM would fix the issue. – Dan Schneider Jul 06 '18 at 20:17
  • Was working on FCM the other day works like a charm on Android P check how to do it here :https://stackoverflow.com/a/48089829/7462031 – FreakyAli Jul 09 '18 at 11:11

1 Answers1

1

You are likely be using an older version of GCM.

You may upgrade to GCM 11 or higher, or even better, migrate to FCM. (GCM is now deprecated)

(The latest GCM version is 15.0.1: com.google.android.gms:play-services-gcm:15.0.1)

OferR
  • 1,634
  • 19
  • 21