Firebase: Is mixing C++ and Java SDK ok? - android

Is it ok to use both the Java and the C++ version of Firebase SDK in one application?
For example I would like to use Crash Reporting to report non-fatal exceptions from Java code and use Remote Config from C++ code. Or in Analytics, I would like to log some events from C++ code and some other events from Java code.
The steps to setup C++ SDK basically include the steps to setup Java SDK, so one gets both either way. But I couldn't find any information whether it is really safe to use that way.

I use it this way. You just need to make sure that you aren't initializing the FIRApp more than once. If you init in your onCreate of your activity and never anywhere else then you should be alright. If you want to be able to init on the C++ side, then you need to check GetInstance() to make sure you aren't already running.
On the C++ side I will perform checks that the App is not null, e.g...
auto app = firebase::App::GetInstance();
if(app)
{
firebase::auth::Auth* auth = firebase::auth::Auth::GetAuth(app);
if(auth)
{
User* user = auth->current_user();
if(user)
{
if(user->is_email_verified() == false)
user->SendEmailVerification();
}
}
}

Related

How to directly invoke AWS Lambda function from an Android app?

I'm trying to invoke one AWS Lambda function from my Android application.
If I understand correctly, I have to start with something like this:
BasicAWSCredentials creds = new BasicAWSCredentials(keyId, secret);
AWSLambdaClientBuilder builder = AWSLambdaClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(creds))
.withRegion(regionName);
AWSLambda lambdaClient = builder.build();
and then the rest of the code with InvokeRequest etc.
Problem is in the above code, after it app crashes. I can't find the correct set of libs to make this work in Android.
If I use
implementation 'com.amazonaws:aws-java-sdk-lambda:1.11.782'
then it compiles fine and executes up to the "builder.build()" and then crashes and if I use
implementation 'com.amazonaws:aws-android-sdk-lambda:2.16.12'
(which is supposed to be used for Android???) Then "import com.amazonaws.services.lambda.AWSLambdaClientBuilder;" is red cause there's no such thing in the lib..
I get that AWSLambdaClient is deprecated and AWSLambda should be used, then what about AWSLambdaClientBuilder? What should I use?
Basically, if everything above is wrong, how do I get to call AWS Lambda function (by the way, this is without using API Gateway) from an Android app? What libs (with versions) would work for it?
I tried to follow https://docs.aws.amazon.com/lambda/latest/dg/with-android-example.html tutorial, but they also have deprecated stuff, plus it wants to involve Cognito and I was under the impression that I could call a function directly with a key and secret of a user with specific policy..
A different approach, but you can use the API gateway or application load balancer and call the configured endpoint from the android application.
Benefit with this, you will not need to configure the application to have the client id, and client secret set up, and even if restart, it would be simple api gateway call.
Lambda can work with both API Gateway as well as Application Load Balancer, and it is pretty easy to configure. Refer this page for details on ALB with Lambda.

Flutter based call recording app with native UI integration

I am trying to get call-recording to work with native UI integration using flutter, CallKit (iOS) and ConnectionService (Android).
Since there is no guide for integrating flutter with CallKit and ConnectionService or any other service to enable system-like call recording without root access or jailbreak, this question has come to existence.
There are a lot of apps available for jailbroken devices and android does natively support call recording, but there is no concrete guide for implementing the same using flutter.
Using flutter 1.7 with AndroidX support for back-compatibility of marshmallow+ ConnectionService.
The expected result is to automatically record calls or prompt user to do so whenever there is an incoming call.
Currently unable to do it at all, maybe I am missing something essential in the documentation or I don't have the sufficient know-how for the successful execution of creating a system-supported call-recording app using flutter.
Since there is no guide for integrating flutter with CallKit and ConnectionService ...
In short, mentioned via comments, you’ll have to refer to https://flutter.dev/docs/development/platform-integration/platform-channels to do it yourself by implementing platform-specific code such as CallKit/ConnectionService.
First, because there’s currently likely no Flutter library that has already conveniently packaged this up for you, at least not at https://pub.dev/flutter, so this is why you need to do it yourself.
Now, assuming all the restrictions, permissions, rooting, jailbreaking, etc. poses no issue to you, then you would need to implement these APIs natively in iOS/Android first, for example, Android:
#Override
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("recordCall")) {
result.success(recordCall());
}
}
Which will then allow you to call them from Flutter:
_recordCall() {
var recording = await platform.invokeMethod('recordCall');
}
So don’t think of how to do this in Flutter, the above was the easy part.
Your perspective should be: how to do this on iOS/Android, because the magic is in recordCall()

Initialize the Fire SDK on Unity for IOS

I just started a project in Unity and I integrated FireBase Analytics.
After some problems I was able to get data from IOS and Android devices so I added some custom events.
I followed the instructions from here and I stared to see results in the dashboard . My problem is that I'm not sure if both IOS and Android are sending the events and I don't know how to separate the event in the dashboard. I'm particularly concerned because I'm not sure if I misunderstood this line of the instructions:
The Firebase Unity SDK on Android requires Google Play services, which must be up-to-date before the SDK can be used. The following code should be added at the start of your application to check for and optionally update Google Play ....
I assumed that the following code had to be added ONLY for Android so I didn't add it to IOS. Can you tell me if I had add this code for IOS too? and how can I check the events for every OS?
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available) {
// Create and hold a reference to your FirebaseApp, i.e.
// app = Firebase.FirebaseApp.DefaultInstance;
// where app is a Firebase.FirebaseApp property of your application class.
// Set a flag here indicating that Firebase is ready to use by your
// application.
} else {
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
// Firebase Unity SDK is not safe to use here.
}
});
Thank you in advance
Well, I was looking for all the day and I found that the filter between OS is in the top left corner of dashboard and event tap as well.
I also used the code for both IOS and Android and I started to get custom event in IOS too.

Auto Update of application using HockeyApp SDK

I am using Android HockeyAppSDK to deploy updates to an application. I am trying to use the docs to customise the default UpdateManager class to allow updates to be installed automatically, without prompting the user to accept the update.
I am quite unsure of how to handle this. The obvious way (in my mind anyway) is to do the following:
private void checkForUpdates () {
UpdateManager.register (this, Constants.HOCKEY_API_KEY, new UpdateManagerListener() {
public void onUpdateAvailable() {
//I assume stuff will need to be handled here
}
});
}
Has anyone done this before, or can find a way to do it?
Many thanks
After emailing the support team for Hockey, they believe that within their current compiled API it is not possible to perform an update without prompting users to accept.
The whole source would require modification and compilation before working as expected it seems.
You can use UpdateTask from library

Logging strategy

I'm about to finish my Android application. In the end I have found that I've been using bunch of logging statements, like:
Log.d(TAG, "Blah-blah");
The question is: for production release what should I do with them?
Just comment/stripe log statements
Do something else more sophisticated? Like as I used to do with Log4J properties or so
Please share your experience.
You can remove the logging statements in build time using an obfuscation tool. See here for details.
There is a new project, which enables log4j on android. Using lo4gj over slf4j is possible. It also provides an appender for LogCat. See project android-logging-log4j or log4j support in android
I have created a library for this specific purpose. It can be found here - LumberJack. You can install it using Jitpack and gradle (Please check README.md).
After installing, you'll have to change all Log calls to LumberJack calls (eg. LumberJack.d() instead of Log.d() etc.)
Tags are optional and by default set to "LumberJack". You can choose to set the default tag yourself.
You can change the filtering anytime using LumberJack.setLogLevel() method. To remove all the logs, you can just set the LogLevel to LogLevel.None.
LumberJack.setLogLevel(LogLevel.None);
So if you just want to remove all the logcat spamming logs, you will just have to set the log level filter.
Optionally you can choose to log into a text file instead of logcat with same filtering mechanism.
I do it like this, making the compiler remove all logging if DEBUG is false:
if (Constant.DEBUG) Log.d(TAG, "mein gott, state is roflcopter");
Depends. If you expect the application to crash often then include one of the crash reporting libraries for example but whatever you decide to do just don't release it with the Log.d() methods.
I've not experience on Android specifically but I'd just leave the logging staements in the code and turn off logging in the log4j properties file. You might even want to leave some logging turned on so that your app will generate useful logs in the event of a crash.
If you are worried about the log statement generation being too computational intensive (e.g. calling toString on a big collection) then you can use this pattern.
if (Log.isDebugEnabled()) {
Log.Debug(bigCollection.toString());
}
If you do not want to log something in Android release version, you can use automatically generated BuildConfig. See more about it here: https://developer.android.com/studio/build/gradle-tips.html. You can also read more information in this question: BuildConfig file in android - Purpose and Possibilities.
So in your code you simply write something like this:
if (BuildConfig.DEBUG) {
//your code just for development goes here
}

Categories

Resources