React-native-push-notification: Installing on android version.

Created on 19 Apr 2017  路  6Comments  路  Source: zo0r/react-native-push-notification

I've been following readme, installed on ios, worked fine. But android does not. Getting java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE error in android studio console.
What did I miss?
Here is my Manifest file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <permission
        android:name="com.example.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.example.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <!--<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>-->

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="22" />

    <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme">
        <meta-data android:name="com.google.android.geo.API_KEY" android:value="****"/>
        <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.example" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
        <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>

      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
          android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>


Stale

Most helpful comment

I'm getting the feeling that this project may be abandoned, @zo0r can we help you maintain it?

All 6 comments

Does adding the following to your build.gradle help you? I'm having issues with Android too. Adding the following crashes my app and otherwise notifications aren't registering.

compile ('com.google.android.gms:play-services-gcm:8.1.0') {
        force = true;
    }

@a-koka I'm having the same problem. did you solve it?

Hi @EyalSi, the docs need to be updated to specify that this step is needed only if you want remote notifications. As a matter of fact, all you need is the following permission in your manifest.xml for local notifications to work.

<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />

I used this to help me get a baseline use case working and built my app from there.

Hope this helps.

I used the new version and works fine

compile ('com.google.android.gms:play-services-gcm:11.0.2') {
      force = true;
  }

I'm getting the feeling that this project may be abandoned, @zo0r can we help you maintain it?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanDance picture DanDance  路  3Comments

NiuQiaoling picture NiuQiaoling  路  3Comments

nidzovito picture nidzovito  路  3Comments

Benzer1406 picture Benzer1406  路  3Comments

selimonline picture selimonline  路  3Comments