Unity android plugin for FCM - android

I'm trying to add Google FCM push notification function to Unity project. I'm surprised that there are no resources about Google FCM for Unity. There are only old Google GCM resources. This is my step-by-step progress below.
Make Android Studio project and register it to a FCM console project
Add google-service.json to '/app' and configure build.gradle (project and module)
Add MyFirebaseInstanceIDService, MyFirebaseMessagingService java classes and onTokenRefresh, sendRegistrationToServer, onMessageReceived, sendNotification methods according to sample example in FCM document
Add services for the classes to AndroidManifest.xml
After that, I tested the Android Studio project on mobile, and FCM console push notification works well. Then, I started to configure the Android Studio project for Unity.
Change 'application' to 'library' in build.gradle (module) and add deleteOldJar, exportJar for AndroidPlugin.jar
Add classes.jar of Unity to Android Studio library and module setting
Remove 'android:icon ...', 'android:theme ...' in AndroidManifest.xml
Export jar and add AndroidPlugin.jar, AndroidManifest.xml to 'Plugins/Android' in Unity
Then, I tested the Unity project on mobile. It is built without exception, but FCM console push notification didn't work. (I made test log for confirming that the Android Studio libray is well plugined for Unity, the log worked well)
Maybe, there are somethings to add to 'Plugins/Android' except AndroidManifest.xml and AndroidPlugin.jar like references below.
Google firebase analytics plugin for unity - StackOverflow
http://joxi.ru/Q2KeQD7C3zdYrj
But, I couldn't find my answer. Please let me know what I have to do or add.
Sorry for bad english and long explanation. Many thanks :)

I used Unity SDK in OneSignal.
It is very simple, easy, and cool SDK for push notification.
Reference link below.
https://onesignal.com/

This approach will not be feasible.
Jar files do not contain resources, and as such, the json file will be missing from the jar build. Alternatively, aar files, which would in theory contain the resources, are interpreted by Unity3D as pure plugin and ignores the resources or at least some, specially when using gradle. But Unity is getting better at it.
Try https://firebase.google.com/docs/unity/setup. It's new and I got the sample project to work already.
Just to add: the new Plugin of Firebase for Unity3D worked liked a charm. Use cases like pure system try notification don't need a single line of additional programming on the client side. Data Messages are very easily implemented as well.

Related

Integrate Flurry SDK and plugin for Unity

I want to add Flurry SDK to my project, but I have a question.
If you go to Flurry's GitHub, if you want to use the push function, it tells you to edit "AndroidManifest.
After installing the Firebase SDK, the "AndroidManifest.xml" file is installed. Delete this file and rename the file "Assets/Plugins/Android/AndroidManifest_Flurry-template.xml" provided by Flurry to "AndroidManifest.xml". Guernsey?
Or I want to know if it is necessary to copy and paste only meta-data in "Flurry AndroidManifest_Flurry-template.xml" to "AndroidManifest.xml" installed when installing Firebase.
Thanks.
If you want to do the merge as the docs also mentioned, then you need to remove the Firebase's part. Keeping those parts will introduce push conflict between Flurry Push and Firebase Messaging.
Yes, you can merge your settings in the same file "AndroidManifest.xml" whenever they won't have any conflict.

How to receive notifications from Firebase Cloud Messaging in React Native

I have a react native project and want to be able to receive notification from FCM. I have set up the project ( generated a google-services.json file for my project, modified the build.gradle files accordingly etc ) but so far I haven't been able to run the project. I am using React Native Firebase library https://rnfirebase.io/ but the experience is just not good so far. I've been stumbling from error to error like the one below:
Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app().
Ensure you have:
1) imported the 'io.invertase.firebase.app.ReactNativeFirebaseAppPackage' module in your 'MainApplication.java' file.
2) Added the 'new ReactNativeFirebaseAppPackage()' line inside of the RN 'getPackages()' method list.
I'm just done trying to get the tooling to work. Can you tell me what other approach I can take to get firebase notifications to work for a React Native project that doesn't make use of the library above ?
Have you followed the suggestions in the error message? Also what could work is deleting the build and cache of your android project, and then rebuilding the application. What version of firebase you are using?

Is google-service.json now obligatory?

Is google-service.json now obligatory ?
In my android app I have added google map and gcm. Now I'm migrating project from eclipse to android studio and I have some little problem.
I have already created a key for gcm, how can I create manually the google-service.json starting from my existing key ?
Another question is :
Initially to add the google play services into my app I followed this official guide :
https://developers.google.com/android/guides/setup
But without this code lines (that I found on stackoverflow):
apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:1.5.0-beta2'
the compiler had not found the play service. Why google doesn't tell nothing about this code line ?
From docs I'd say yes, it's needed. If you follow the line guide you can download a json file even you have already created your project in the developer console. There is a "configuration file" button here. In addition the lines you see "apply plugin" and "classpath" are only for Android Studio (the official IDE). Using the setup suggested it's really easy to setup the project with Android Studio.

Unable to build Android app FabricGenerateResourcesDebug

I'm trying to integrate twitter's sdk with my app. I'm following this guide.
Unfortunately, when I try to build my project, I keep receiving this error:
Error:Execution failed for task ':app:fabricGenerateResourcesDebug'.
Crashlytics Developer Tools error.
Unfortunately because I don't have 10 reputation, I can't post my build.gradle file because it has links in it. Just trust the fact that it looks just like the build.gradle example in the top link provided.
Is there something that I'm missing that I may have overlooked?
Your problem should be caused due to that you did not create a “crashlytics.properties” file which is required to contain API Key and Build Secret in your app directory.
The solution is quite simple that you don't even have to manually setup anything on your original project. Just following this link:
https://fabric.io/settings/organizations
It will lead you to the Fabric official website, which helps you to download and install Fabric plugins into your IDE (Android Studio, IntelliJ or Eclipse). This might be a new magical method to integrate twitter's SDK within your app, it will automatically configure your project. You will see the magic when you get there.
Hope it helps.
The fix I found is that I did not place the meta-data tag with the API Key INSIDE the application tag in the androidmanifest.xml.

Add gcm.jar in Eclipse IDE (Google Cloud Messaging)

I have a problem as:
I didn't find where can I get this Jar file gcm.jar? also where Can I put it ?.
Note I used Android 4.1.
Start SDK Manager and scroll down to the section "Extras" and make sure you have installed Google Cloud Messaging for Android Library, if not, install the package.
The package will be installed in the directory "your-android-sdk\extras\google\gcm\"
Client code (for example to be used in Android app):
gcm\gcm-client\
Server code (where the Client connects to and registers it's regId):
gcm\gcm-server\
To add the gcm client-jar (gcm.jar) to your Android-project, copy it to the "libs"-folder in your Eclipse project and right click on the file and select Build Path --> Add to Build Path.
The GCM Helper libraries (gcm.jar) has been deprecated.
The documentation for the library (https://developer.android.com/google/gcm/helper.html)
now displays a messaging stating:
The information in this document has been superseded by GCM Server and GCM Client. Please use the GoogleCloudMessaging API instead of the GCM client helper library. The GCM server helper library is still valid.
Implementing a GCM server is documented here: https://developer.android.com/google/gcm/server.html
Implementing a GCM client is now documented here: developer.android.com/google/gcm/client.html (sorry, can't post as a link because I don't have enough rep).
As on today's date, SDK Manager now has the option to "Show obsolete packages" (Packages->Show obsolete packages). This allows you to install GCM through the SDK Manager itself.
Go to this link
https://dl-ssl.google.com/android/repository/gcm_r03.zip
when download completes extract the zip file, you will get three directories with names client side, server side and samples.
now open your SDK folder and create a folder named "extras/android" and paste all three folders here DONE!!
now whenever make a new project in project classpath using add external jar add gcm.jar.
refer
Just for the Recored: I followed the steps provided by chrkad but I found the .jar file in the DIST folder and NOT in the JAR folder. After I found that out I saw that Peter Gluck postet that before.
I hope that this could save some time to ppl having this issue! (took me 20 minutes)
Seems like this package is now obsolete. In order to see it in SDK Manager I had to check "Show obsolete packages" in the "Packages" menu
See details from answer
https://stackoverflow.com/a/23092848/4255980

Categories

Resources