Unity3D firebase AUTH not working on ANDROID fierbase doesnt connect or something - unity3d

in editor work fine. i am trying to add my project fierbase and in work. but when i start test at android login window dont react. i am trying to do this
Unity3D firebase AUTH not working on ANDROID
public class FirebaseINIT : MonoBehaviour
{
public static bool firebaseReady;
void Start()
{
CheckIfReady();
}
void Update()
{
if(firebaseReady == true)
{
SceneManager.LoadScene("LoginScene");
}
}
public static void CheckIfReady()
{
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
Firebase.DependencyStatus dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
firebaseReady = true;
Debug.Log("Firebase is ready for use.");
}
else
{
firebaseReady = false;
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
}
});
}
}
but not loaded next scene. and i am confused why this happen, i cant do next because dont understand problem. May this will be from android resolve? Because in order to build the project, I must remove the Resolved libraries.
otherwise if I don't remove assets=> Android=> resolve libraries then I will get the following errors
Configure project :launcher
WARNING: The option setting 'android.enableR8=false' is deprecated.
Execution failed for task ':launcher:processReleaseResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
the project has an additional plugin for advertising appodeal + admob at least the direction of movement of the study of the issue
and i am integrate this first time i am not sure i am at the right way

Related

Plugin.LocalNotification doesn't build in Release Mode

I try to add LocalNotification to the application, everything works in Debug mode, but when I change to Release mode, notifications do not work.
Anyone know how to deal with it?
using Plugin.LocalNotification;
namespace TestNotif;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseLocalNotification()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
return builder.Build();
}
}
I got this error CS1061:
Severity Code Description Project File Line Suppression State
Error CS1061 'MauiAppBuilder' does not contain a definition for
'UseLocalNotification' and no accessible extension method
'UseLocalNotification' accepting a first argument of type
'MauiAppBuilder' could be found (are you missing a using directive or
an assembly reference?) TestNotif (net6.0-maccatalyst), TestNotif
(net6.0-windows10.0.19041.0) C:\Users---\source\repos\TestNotif\TestNotif\MauiProgram.cs 14 Active
using Plugin.LocalNotification;
using System;
namespace TestNotif;
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
NotificationGet();
}
public async void Button_Clicked(object sender, EventArgs e)
{
var notification6 = new NotificationRequest
{
BadgeNumber = 1,
Description = "Test Description",
Title = "Notification!",
ReturningData = "Dummy Data",
NotificationId = 1327,
Schedule =
{
NotifyTime = DateTime.Now.AddSeconds(5)
}
};
await LocalNotificationCenter.Current.Show(notification6);
}
Fix #1: Only build for Android, to avoid errors when Maui attempts to build release for MacCatalyst and Windows:
Rt-click your Maui project, "Properties".
Application > General, find "iOS Targets > Target the iOS platform: Enable targeting of the iOS platform. UNCHECK.
Similarly find and UNCHECK: Windows Targets > Target ..: Enable targetting of the Windows platform.
Fix #2: Notifications don't work on Android:
Test on an actual device, not on an emulator.
If after both of these, it still doesn't work, then contact author of that plug-in for help.

Unity WebGL throws Error: "ReferenceError: Runtime is not defined"

I wanted to export my Unity project (Unity Version 2021.2) for WebGL, but I get this Error:
An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:
ReferenceError: Runtime is not defined unityFramework/_WebSocketConnect/instance.ws.onopen#http://localhost:55444/Build/WEbGL.framework.js:3:67866
I am using this Websocket package (https://github.com/endel/NativeWebSocket) an everything is working fine in Unity or in a Windows Build. When i run the WebGL build it does connect with the websocket but then i get the Error.
The Error message says more info is in my console but the console on F12 only repeats the error:
Uncaught ReferenceError: Runtime is not defined
at WebSocket.instance.ws.onmessage (WEbGL.framework.js:3)
instance.ws.onmessage # WEbGL.framework.js:3
To give a minimal reproducable example i just created a empty 3D Core project with Unity 2021.2 and imported the package NativeWebSocket (I downloaded the File from GitHub and installed it manally:
Copy the sources from NativeWebSocket/Assets/WebSocket into your Assets directory
Then you have to make the fixes postet by kentakang on https://github.com/endel/NativeWebSocket/pull/54 otherwise the build will fail.
Then i made a new C# script with the code below (also from the Github page) and put it on the Camera in the Scene. I exported it for WebGL and got the mentioned Error.
This happens when one of the Methods websocket.OnOpen/OnError/OnClose/OnMessage is called, so you donĀ“t even need a running websocket because then websocket.OnError is called and the WebGL Build throws the "Runtime is not defined" Error. Or if you have also the running Websocket server which is also included in the package you get the Error when websocket.OnOpen is called.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NativeWebSocket;
public class Connection : MonoBehaviour
{
WebSocket websocket;
// Start is called before the first frame update
async void Start()
{
websocket = new WebSocket("ws://localhost:2567");
websocket.OnOpen += () =>
{
Debug.Log("Connection open!");
};
websocket.OnError += (e) =>
{
Debug.Log("Error! " + e);
};
websocket.OnClose += (e) =>
{
Debug.Log("Connection closed!");
};
websocket.OnMessage += (bytes) =>
{
Debug.Log("OnMessage!");
Debug.Log(bytes);
// getting the message as a string
// var message = System.Text.Encoding.UTF8.GetString(bytes);
// Debug.Log("OnMessage! " + message);
};
// Keep sending messages at every 0.3s
InvokeRepeating("SendWebSocketMessage", 0.0f, 0.3f);
// waiting for messages
await websocket.Connect();
}
void Update()
{
#if !UNITY_WEBGL || UNITY_EDITOR
websocket.DispatchMessageQueue();
#endif
}
async void SendWebSocketMessage()
{
if (websocket.State == WebSocketState.Open)
{
// Sending bytes
await websocket.Send(new byte[] { 10, 20, 30 });
// Sending plain text
await websocket.SendText("plain text message");
}
}
private async void OnApplicationQuit()
{
await websocket.Close();
}
}
Does someone know how to fix this Error? Help would be appreciated:)
It seams that in unity 2021.2 variable Runtime doesn't exist and can be replaced with Module['dynCall_*'].
In webSocket.jslib change all Runtime.dynCall('*1', *2, [*3, *4]) for Module['dynCall_*1'](*2, *3, *4)
Example instance.ws.onopen function in WebSocket.jslib:
change Runtime.dynCall('vi', webSocketState.onOpen, [ instanceId ]);
for
Module['dynCall_vi'](webSocketState.onOpen, instanceId);

Having issue with Battery status in Ionic 4

I'm using Ionic4 and I'm trying to get the device battery level. But I get an error:
ERROR TypeError: Invalid event target
and for the battery level, I get undefined.
Has anyone run into the same problem
There is an open bug report at ionic: https://github.com/ionic-team/ionic-native/issues/2972
Unfortunately no solution yet, however there is a workaround to bypass the ionic typescript wrapper and just listen directly on the window events.
fromEvent(window, 'batterystatus').subscribe((status) => {
console.log(status)
});
This is how I managed to get the battery status in Ionic 4:
window.addEventListener('batterystatus', this.onBatteryStatus, false);
onBatteryStatus(status) {
console.log('Level: ' + status.level + ' isPlugged: ' + status.isPlugged);
}
An easy way could be like this:
$ ionic cordova plugin add cordova-plugin-battery-status
$ npm install --save #ionic-native/battery-status#4
Then in your code:
import { Platform } from 'ionic-angular';
import { BatteryStatus } from '#ionic-native/battery-status';
batterylevel = 0;
constructor(...
private batteryStatus: BatteryStatus,
private plt: Platform ) {}
ionViewDidEnter()
{
// Cordova check
if(this.plt.is('core') || this.plt.is('mobileweb'))
{
// NO. It's a browser.
// don't call the batery.
}
else
{
const batterysubscription = this.batteryStatus.onChange().subscribe(status => {
this.batterylevel = status.level;
});
}
}
yourfunction()
{
console.log(this.batterylevel);
}
You'll also need to add it to your provider list too.
Of course, this will only work in emulation or a device.

Detecting an incoming call in my Unity app

I am trying to make my game pause on incoming phone call. I am wondering if any of this functions which I used can do this. I have used them in my source code but none of them worked.
void OnApplicationPause(bool paused)
{
if (paused == true)
{
if (!isPaused)
PauseResume(true);
}
}
void OnApplicationFocus(bool hasFocus)
{
if (hasFocus == false)
{
if (!isPaused)
PauseResume(true);
}
}
Also i had found Application.runInBackground() but it is mentioned in documentation that "Note: This property is ignored on Android and iOS".
In iOS and Android, OnApplicationPause(...) is expected to be called. This user had the same issue: https://forum.unity.com/threads/onapplicationpause-not-being-called-in-ios-build.455426/
His answer was:
Apparently, it was not working because I had 'Behaviour in Background' set to Custom instead of Suspend...

How do I get the price from AdMob in Unity AIP?

I am trying to pull in the price for In App Purchases (IAP) using Unity Ads and AdMob.
public void InitializePurchasing()
{
// If we have already connected to Purchasing ...
if (IsInitialized())
{
// ... we are done here.
return;
}
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
builder.AddProduct(PRODUCT_REMOVE_ADS, ProductType.NonConsumable);
UnityPurchasing.Initialize(this, builder);
removeAdsPriceText.text = m_StoreController.products.WithID("removeads").metadata.localizedPrice.ToString(); // This should be the code to get the price
}
Price in the Editor when I hit play:
This is the price when I build the app to Google Play and run the app.
It is suppose to be $1.99.
Am I missing a step?
I finally figured out the solution
The code needs to be called OnInitialized
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
{
m_StoreController = controller;
m_StoreExtensionProvider = extensions;
removeAdsPriceText.text = m_StoreController.products.WithID("removeads").metadata.localizedPriceString;
}
Thanks everyone for the help!