OneSignal / OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Other
604 stars 368 forks source link

Cocos2d-x SDKBox - Eclipse project issue on Android 8.1 #630

Closed smitpatel88 closed 6 years ago

smitpatel88 commented 6 years ago

If our target targetSdkVersion is 27 which is now compulsory then Oreo devices is not able to get push notifications. When Android-8.1 device getting notification, below log is printed in adb

NotificationService: No Channel found for pkg=com.game.name, channelId=null, id=-1217830295, tag=null, opPkg=com.game.name, callingUid=10473, userId=0, incomingUserId=0, notificationUid=10473, notification=Notification(channel=null pri=0 contentView=null vibrate=default sound=android.resource://com.game.name/2131099649 tick defaults=0x6 flags=0x11 color=0x00000000 vis=PUBLIC)

Testing with Cocos2d-x via sdkbox, which is using Eclipse project jar file. I tried replacing latest jar file 3.10 but same result.

jkasten2 commented 6 years ago

@smitpatel88 In addition to updating the OneSignal .jar you will need to make sure you have the Android Support Library 26 newer in your project as well.

Lastly I believe there have been some changes to the AndroidManifest.xml so make sure to add the same ones noted here: https://documentation.onesignal.com/docs/android-sdk-setup-eclipse#section-2-androidmanifest-xml

smitpatel88 commented 6 years ago

Okay, i delete android_support_v7 folder from project\cocos2d\cocos\platform\android\java\libs and added below 2 lines in build.gradle

compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:support-v4:27.1.1'

And after that its working fine. BUT i am getting below log when OneSignal initialize

I SDKBOX_CORE: Initialization request for plugin: 'com/sdkbox/plugin/PluginOneSignal'
W OneSignal: GCM Library detected, please upgrade to Firebase FCM library as GCM is deprecated!
E DEFAULT : OneSignal: plugin onesignal init native fail
W System.err: java.lang.IllegalArgumentException: Component class com.google.firebase.iid.FirebaseInstanceIdService does not exist in com.game.name
W System.err:    at android.os.Parcel.readException(Parcel.java:1687)
W System.err:    at android.os.Parcel.readException(Parcel.java:1636)
W System.err:    at android.content.pm.IPackageManager$Stub$Proxy.setComponentEnabledSetting(IPackageManager.java:4356)
W System.err:    at android.app.ApplicationPackageManager.setComponentEnabledSetting(ApplicationPackageManager.java:2088)
W System.err:    at com.onesignal.PushRegistratorFCM.disableFirebaseInstanceIdService(PushRegistratorFCM.java:65)
W System.err:    at com.onesignal.OneSignal.init(OneSignal.java:662)
W System.err:    at com.onesignal.OneSignal.init(OneSignal.java:574)
W System.err:    at com.sdkbox.plugin.PluginOneSignal.nativeInit(PluginOneSignal.java:73)
W System.err:    at org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method)
W System.err:    at org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:73)
W System.err:    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1521)
W System.err:    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)
E OneSignal: You must initialize OneSignal before getting tags! Moving this tag operation to a pending queue.

Can we ignore this warning?

rampr commented 6 years ago

I think this has been fixed in #626

jkasten2 commented 6 years ago

@rampr Thanks, for replying, you're right.

@smitpatel88 As a work around you can use FCM in your project instead of GCM.

compile 'com.google.firebase:firebase-messaging:12.0.1'