Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 127

miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
10/27/16 09:57 AM (7 years ago)

OneSignal PN in Android Studio error

I use OneSignal PN in iOS apps and works fine, but in Android it doesn't. I followed manuals: https://www.dropbox.com/s/65w171glhwld32f/OneSignal%20GCM%20BT%203%20Android.pdf?dl=0 Compiling works, but app doesn't. I asked people from OneSignal and they send me this: “Our SDK does not use `com.google.android.c2dm.intent.REGISTRATION` so this must be coming from another SDK/plugin in your app.” So I deleted this in manifest: <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> Can anybody tell what could I do this to work?
 
330ministries
buzztouch Evangelist
Profile
Posts: 15
Reg: Sep 19, 2012
Owasso, OK
2,900
like
11/02/16 12:40 PM (7 years ago)
I just used OneSignal for PN in an Android app. I think the dropbox instructions you are using are outdated. I tried using it as well and since OneSignal recently launched a new version, I had trouble going that route as well. This is what I did in Android Studio: (1) I followed the OneSignal instructions (2) Then in my BT control panel (Core), I did NOT turn on push notifications. I also didn't edit anything out of the manifest either. The new OneSignal version will automatically add whatever is needed to the manifest - Nothing to do manually. (3) I changed my Configuration date "currentMode":"Live" - I don't know if this makes a difference with Android but I know it needs to be set to "Live" to work on Apple. According to OneSignal instructions, I made the changes to the BT_activity_host file: Added: import com.onesignal.OneSignal; // added line for OneSignal Then: //onCreate @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); OneSignal.startInit(this).init(); // added OneSignal // OneSignal.enableNotificationsWhenActive(true); // enables visibility with app in foreground // OneSignal.enableInAppAlertNotification(true); // optional, enables BT_debugger.showIt(activityName + ":onCreate"); Don't drag into your library any OneSignal jar files, as some suggested - This gives you a duplex error. Here's what my Module: App Gradle file looks like: apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion '23.0.2' useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.nameofapp" manifestPlaceholders = [manifestApplicationId : "${applicationId}", onesignal_app_id : "[put your OneSignal number here]", onesignal_google_project_number: "[put your Google Project number here]"] minSdkVersion 14 targetSdkVersion 19 versionCode 5 versionName "1.5" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { } } dependencies { //compile possible .jar files in the libs directory... compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.onesignal:OneSignal:3.+@aar' compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:design:24.2.0' compile 'com.google.android.gms:play-services-appindexing:9.4.0' compile 'com.google.android.gms:play-services-gcm:9.4.0' } We do a lot more iOS apps than Android but I hope that helps. Also, right now the app shuts down if you're in the app when a notification comes. The notification is still received but it kicks you out. We haven't made the changes yet, but when we asked OneSignal about it, they replied as follows: Hello, Here is the link to our new inFocusDisplaying section. And our 3.0 upgrade guide if you still need it. https://documentation.onesignal.com/docs/upgrading-to-android-sdk-30
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
11/07/16 11:17 AM (7 years ago)
You are right, it works now. Thanks!
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
11/10/16 08:03 AM (7 years ago)
Sorry, I was happy too early. I realised that it doesn't work, just like never was in any of my Android apps. OneSignal works fine on iOS devices and is real shame that nobody of BT community wants to solve this.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.