williamrijksen / com.williamrijksen.onesignal

Titanium Appcelerator Library for OneSignal Push Notifications Service
Other
51 stars 43 forks source link

Firebase support - internal dependencies #83

Open antonioduran opened 5 years ago

antonioduran commented 5 years ago

Hello. As you know google will be deprecated GCM in April 11th, so this module is working with GCM, but does anybody know whether this module will have support for firebase? I mean to update all the internal dependencies of the module to firebase.

Thanks.

chmiiller commented 5 years ago

We really need to work this out. I have no knowledge on that part of the module. Do you know who started the implementation of it on Android? @jvandijk Jeroen, maybe you know something or someone?

jvandijk commented 5 years ago

I haven't tested this, but as far as I can see this has been completely abstracted away by the OneSignal library itself. This still supports both GCM & FCM, it's just up to you to configure one in the OneSignal user interface and only use the OneSignal app id. In the past you also had to put in a Google project number, but is now fetched automatically to support both GCM & FCM.

antonioduran commented 5 years ago

Hey hello @jvandijk. Perhaps, I am wrong, but what about the following; not sure, but this module seems that it is not using FCM SDK, but according to Google we should remove / update the following:

Switch to FCM in the app-level build.gradle

Before

dependencies {
compile "com.google.android.gms:play-services-gcm:16.0.0"
}

After

dependencies {
  compile "com.google.firebase:firebase-messaging:17.3.4"
}

FCM SDK automatically adds all required permissions as well as the required receiver funtionality. Make sure to remove the following obsolete (and potentially harmful, as they may cause message duplication) elements from your app's manifest:

Remove from AndroidManifest.xml

<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission android:name="<your-package-name>.permission.C2D_MESSAGE"
            android:protectionLevel="signature" />
<uses-permission android:name="<your-package-name>.permission.C2D_MESSAGE" />

...

<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.gcm" />
    </intent-filter>
</receiver>

I noticed part of the above code in the following link: https://github.com/williamrijksen/com.williamrijksen.onesignal/blob/5714d54ea70745092725d6e70ea8a363c4738ae1/android/timodule.xml

Reference: https://developers.google.com/cloud-messaging/android/android-migrate-fcm

AndreaVitale commented 5 years ago

Got it to work:

removed all stuffs from manifest like @antonioduran says and now I get inside the console

[WARN] OneSignal: Both GCM & FCM Libraries detected! Please remove the deprecated GCM library.

Unfortunately I think that we cannot completely remove GCM because is built in inside ti.playservices module.

deckameron commented 4 years ago

In case you would like to test it with FCM, here is the module.