Android推送通知,不授予权限

时间:2016-02-22 11:43:24

标签: android push-notification react-native

我尝试使用this package

在我的Android应用(内置于react-native)上启用通知

以下是 MANIFEST.XML 文件的一部分:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="{package_name}"
 android:versionCode="1"
 android:versionName="1.0.0"
 android:minSdkVersion="21"
 android:targetSdkVersion="23">

<permission
    android:name="com.xxx.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.xxx.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.google.android.c2dm.permission.SEND" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_TASKS" /> 

...

<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.xxx" />
  </intent-filter>
</receiver>
<service android:name="com.oney.gcm.GcmRegistrationService"/>
<service android:name="com.oney.gcm.BackgroundService"></service>

<service
  android:name="com.oney.gcm.RNGcmListenerService"
  android:exported="false" >
  <intent-filter>
    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
  </intent-filter>
</service>
<receiver
  android:exported="false"
  android:name="com.oney.gcm.GcmBroadcastReceiver">
  <intent-filter>
    <action android:name="com.oney.gcm.GCMReceiveNotification" />
    </intent-filter>
</receiver>

<receiver android:name="io.neson.react.notification.NotificationEventReceiver" />
<receiver android:name="io.neson.react.notification.NotificationPublisher" />
<receiver android:name="io.neson.react.notification.SystemBootEventReceiver">
  <intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED"></action>
  </intent-filter>
</receiver>

不幸的是,当我安装我的应用程序时,我在日志中有这个:

W/PackageManager( 873): Not granting permission com.google.android.c2dm.permission.SEND to package (protectionLevel=18 flags=0x8be46)

关于这个问题的任何想法?

感谢。

2 个答案:

答案 0 :(得分:1)

您的项目级别存在C2DM设置问题。请执行official doc或按照此tutorial一步一步。

更改Manifest.xml

时要做的步骤
  • 接收C2DM消息的权限
  • 访问互联网
  • 限制对C2DM消息的访问,以便其他应用无法看到它们
  • 声明我们稍后将创建的接收器,它将让我们接收C2DM事件
  • 确保设置minSdkVersion,以便只有2.2及更高版本才能访问您的应用

答案 1 :(得分:0)

我认为因为您使用弃用的api

  

重要提示:C2DM于2012年6月26日正式弃用   截至2015年10月20日完全关闭。现有C2DM   鼓励开发人员迁移到Google Cloud Messaging(GCM)。   有关更多信息,请参阅C2DM-to-GCM迁移文档。   开发人员必须使用GCM进行新的开发。

https://developers.google.com/android/c2dm/?csw=1#manifest

相关问题