我在Unity3D中使用https://github.com/kobakei/unity-gcm進行GCM通知。我收到設備上的消息。當我點擊通知時,沒有任何反應。我希望應用程序啓動。這是日誌:設備上收到的GCM通知未啓動應用程序
V/GCMRegistrar(8441): Setting the name of retry receiver class tocom.kskkbys.unitygcmplugin.UnityGCMBroadcastReceiver
V/UnityGCMBroadcastReceiver(8441): getGCMIntentServcieClassName
V/GCMBroadcastReceiver(8441): GCM IntentService class: com.kskkbys.unitygcmplugin.UnityGCMIntentService
V/GCMBaseIntentService(8441): Acquiring wakelock
D/ConnectivityService( 845): handleInetConditionHoldEnd: net=0, condition=100, published condition=100
V/GCMBaseIntentService(8441): Intent service name: GCMIntentService-DynamicSenderIds-1
D/STATUSBAR-NetworkController(1051): onReceive() - CONNECTIVITY_ACTION, INET_CONDITION_ACTION
V/UnityGCMIntentService(8441): onMessage
V/UnityGCMIntentService(8441): ticker: ticker
D/STATUSBAR-NetworkController(1051): getUpdateDataNetType() - mDataNetType:15
D/STATUSBAR-NetworkController(1051): updateDataNetType()
D/STATUSBAR-NetworkController(1051): Nothing, mRoamingIconId = 0
V/UnityGCMIntentService(8441): foo: bar
V/UnityGCMIntentService(8441): from: xxxxx
V/UnityGCMIntentService(8441): content_title: New Friend Request
V/UnityGCMIntentService(8441): score: 123
V/UnityGCMIntentService(8441): is_first: true
V/UnityGCMIntentService(8441): content_text: test
V/UnityGCMIntentService(8441): collapse_key: do_not_collapse
D/dalvikvm(8441): Trying to load lib /data/app-lib/com.company.app-23/libmain.so 0x42587730
D/dalvikvm(8441): Added shared lib /data/app-lib/com.company.app-23/libmain.so 0x42587730
W/dalvikvm(8441): No implementation found for native Lcom/unity3d/player/UnityPlayer;.UnitySendMessage:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
W/System.err(8441): java.lang.UnsatisfiedLinkError: Native method not found: com.unity3d.player.UnityPlayer.UnitySendMessage:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
W/System.err(8441): at com.unity3d.player.UnityPlayer.UnitySendMessage(Native Method)
W/System.err(8441): at com.kskkbys.unitygcmplugin.Util.sendMessage(Util.java:23)
W/System.err(8441): at com.kskkbys.unitygcmplugin.UnityGCMIntentService.onMessage(UnityGCMIntentService.java:50)
W/System.err(8441): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
W/System.err(8441): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
W/System.err(8441): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(8441): at android.os.Looper.loop(Looper.java:136)
W/System.err(8441): at android.os.HandlerThread.run(HandlerThread.java:61)
V/UnityGCMNotificationManager(8441): showNotification
V/GCMBaseIntentService(8441): Releasing wakelock
W/ContextImpl( 845): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1505 com.android.server.StatusBarManagerService.sendNotification:985 com.android.server.StatusBarManagerService.addNotification:674 com.android.server.NotificationManagerService$7.run:2157 android.os.Handler.handleCallback:733
和
W/ContextImpl( 845): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1505 com.android.server.StatusBarManagerService.sendNotification:985 com.android.server.StatusBarManagerService.removeNotification:710 com.android.server.NotificationManagerService.cancelNotificationLocked:2469 com.android.server.NotificationManagerService.access$5100:162
D/STATUSBAR-StatusBarManagerService( 845): sendNotification(3) - 1
編輯: 的AndroidManifest.xml:
<!-- Android GCM Plugin -->
<receiver android:name="com.kskkbys.unitygcmplugin.UnityGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.company.application" />
</intent-filter>
</receiver>
<service android:name="com.kskkbys.unitygcmplugin.UnityGCMIntentService" />
<!-- Android GCM Plugin -->
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Android GCM Plugin -->
<permission android:name="com.company.application.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.company.application.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<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" />
<!-- Android GCM Plugin -->
EDIT2: 這是在logcat中出現的錯誤當我觸摸通知圖標並希望應用程序啓動時。
Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1505 com.android.server.StatusBarManagerService.sendNotification:985 com.android.server.StatusBarManagerService.removeNotification:710 com.android.server.NotificationManagerService.cancelNotificationLocked:2469 com.android.server.NotificationManagerService.access$5100:162
我張貼的清單的問題。對我來說,它似乎工作。我從設備上卸載了應用程序並重建了它。沒有區別。 我沒有發佈任何代碼,因爲我使用unity-gcm插件,它不需要任何android代碼。 – cancerballs 2015-01-21 14:44:23