Xamarin.Firebase.Auth wont work when install Xamarin.Firebase.Messages - xamarin

I'm struggling to understand why when I install Xamarin.Firebase.Messaging the auth is null in the code below:
private void InitFirebaseAuth()
{
app = FirebaseApp.Instance;
auth = FirebaseAuth.GetInstance(app);
using (var user = auth.CurrentUser)
{
if (user != null)
{
StartActivity(new Intent(this, typeof(MainActivity)));
Finish();
}
}
}
auth = FirebaseAuth.GetInstance(app) is null, when I uninstall Xamarin.FIrebase.Messaging everything works fine.
I think that there is something with NuGet packages but I can't resolve this problem.
The version of packages like the foto below:
Any help, please?
EDIT
I reinstalled Visual Studio and now I can see this nuget packages:
Nad when I try to downgrade Xamarin.Android.Auth there is this error:
Severity Code Description Project File Line Suppression State Suppression State
Error NU1107 Version conflict detected for Xamarin.GooglePlayServices.Base. Install/reference Xamarin.GooglePlayServices.Base 71.1610.0 directly to project Hearth to resolve this issue.
Hearth -> Xamarin.Firebase.Core 71.1601.0 -> Xamarin.Firebase.Measurement.Connector.Impl 71.1704.0 -> Xamarin.Firebase.Analytics.Impl 71.1624.0 -> Xamarin.Firebase.Iid 71.1710.0 -> Xamarin.Firebase.Iid.Interop 71.1601.0 -> Xamarin.GooglePlayServices.Base (>= 71.1610.0)
Hearth -> Xamarin.Firebase.Auth 60.1142.1 -> Xamarin.GooglePlayServices.Base (= 60.1142.1). Hearth C:\Users\HP\Documents\Projects\Develop\Hearth\Hearth.csproj 1

Related

How to use Microsoft Graph Toolkit with SPFX 1.15.2

I created a new SPFX solution with yo. Then I followed this guide:
Installed with
npm install #microsoft/mgt-spfx
and
npm install #microsoft/mgt-react
Then I changed the init method in the webpart.ts file to following code
protected onInit(): Promise<void> {
if (!Providers.globalProvider) {
Providers.globalProvider = new SharePointProvider(this.context);
}
return super.onInit();
}
Added the import
import { SharePointProvider, Providers } from '#microsoft/mgt-spfx';
In the tsx component file I changed the render to
public render(): React.ReactElement<IPeoplePickerTestProps> {
return (
<div>
Test
<Person personQuery="me" view={ViewType.image}></Person>
</div>
);
}
and added the import
import { Person, ViewType } from '#microsoft/mgt-react/dist/es6';
Then I uploaded the latest toolkit spfx package (got it here) to the app catalog (deployed to all sites), builded my solution (gulp bundle --ship, gulp package-solution --ship) and uploaded it to the app catalog. Created a new site collection and installed my solution. Its not working at all. There is nothing rendered except the text "Test". In the console I can see following error which does not really help me:
Toolkit version: 2.6.1
SPFX version: 1.15.2
Tested on different tenants.
I got similar issue, try importing from
#microsoft/mgt-react/dist/es6/spfx
so:
import { Person } from '#microsoft/mgt-react/dist/es6/spfx';
import { ViewType } from '#microsoft/mgt-spfx';
Hope that helps

FilePicker class cannot be found in Xamarin project

I'm creating a Xamarin forms app which enables user uploads. I have installed the latest version of the Xamarin.Essentials package but the classes and methods which I would expect to be available cannot be found. I can move ahead with the xamarin.plugins.filepicker package but this is not well documented and I would prefer to use the standard library. Any assistance with this would be greatly appreciated! The default is below.
'''
async Task<FileResult> PickAndShow(PickOptions options)
{
try
{
var result = await FilePicker.PickAsync();
if (result != null)
{
Text = $"File Name: {result.FileName}";
if (result.FileName.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) ||
result.FileName.EndsWith("png", StringComparison.OrdinalIgnoreCase))
{
var stream = await result.OpenReadAsync();
Image = ImageSource.FromStream(() => stream);
}
}
}
catch (Exception ex)
{
// The user canceled or something went wrong
}
}
'''
For the Xamarin.Essentials package, update to the latest version on both Xamarin.Form NuGet Package and Android NuGet Package. After that you could fix the errors like below.
Error CS0246 The type or namespace name 'PickOptions' could not be found (are you
missing a using directive or an assembly reference?)
For the usage of Xamarin.Essentials: File Picker, you could check the MS document.
https://learn.microsoft.com/en-us/xamarin/essentials/file-picker?tabs=android
If you wanna the source file, you could download from the link below. https://github.com/xamarin/Essentials/tree/main/Xamarin.Essentials/FilePicker

How to download and open a file with NS 6.0

I'have migrate to NativeScript 6.0 and need some help on how to download and open a file with Android support lib (AndroidX) in the Downloads folder.
Actually, in NS 5.x, i have used FileProvider from Android support lib (android.support.v4.content.FileProvider) and works great. After the migration, using (androidx.core.content.FileProvider), i have errors opening the App.
But in Android docs, i can't find any method or information to migrate the code for Native download and Open (Downloads Folder).
Previous Method:
private openFile(fileName: string, mimeType: string, extension: string) {
try {
if (isAndroid) {
const intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
const context = applicationModule.android.context;
console.log("android.ctx=", context);
const nativeFile = new java.io.File(fileName);
console.log("nativeFile=", nativeFile);
const uri = android.support.v4.content.FileProvider.getUriForFile(context, "com.otisw.gescon.app.provider", nativeFile);
intent.setDataAndType(uri, mimeType);
intent.addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION);
const choosedIntent = android.content.Intent.createChooser(intent, "Open file...");
console.log("choosedIntent=>", choosedIntent);
context.startActivity(choosedIntent);
} else {
// const documents = fs.knownFolders.currentApp();
// const file = this.documents.getFile(fileName);
const open = utils.ios.openFile(fileName);
}
} catch (e) {
console.log(e);
}
}
Tried:
private openFile(fileName: string, mimeType: string, extension: string) {
try {
if (isAndroid) {
const intent = androidx.core.content.IntentCompat.makeMainSelectorActivity(
"android.content.Intent.ACTION_VIEW",
"??"
);
File reference.d.ts:
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android/androidx-26.d.ts" />
Does anyone tries to upgrade the code for Download and Open from NativeScript to new AndroidX or knows a workaround to do this ?
Thanks!
You will have to use androidx.core.content.FileProvider on AndoridX and android.support.v4.content.FileProvider in lower versions.
With the release of Android 9.0 (API level 28) there is a new version
of the support library called AndroidX which is part of Jetpack. The
AndroidX library contains the existing support library and also
includes the latest Jetpack components.
You can continue to use the support library. Historical artifacts
(those versioned 27 and earlier, and packaged as android.support.*)
will remain available on Google Maven. However, all new library
development will occur in the AndroidX library.
We recommend using the AndroidX libraries in all new projects. You
should also consider migrating existing projects to AndroidX as well.

"GattDeviceServicesResult" can not be found

I am trying to create client side app using C# for BluetoothLE in VisualStudio 2015 on Windows-10 laptop.
I have problem using Windows.Devices.Bluetooth.GenericAttributeProfile, the issue is my code has compile error saying GattDeviceServicesResult can not be found.
-> I have added package UwpDesktop 10.0.14393.3 by Valdimir Postel... (before installing this even "using Wndows.Devices.Bluetooth" was not working)
-> Then I added SDK, windows Kit that was recommended by VisualStudio when I tried to open one of the example (So I accept the recommendation to build that project and VS installed packages of around 9GB)
-> now I can use some of the Bluetooth api's I can scan and connect to a BLE device, but I can not use classes to deal with services and characteristics because GattDeviceServicesResult and GattCharacteristicsResult types are not found. Although these are mentioned on MSDN website
-> searching in forums I came to know I need to add one more reference System.Runtime.WindowsRuntime.dll, I browsed to proper folder through add reference utility of VS, I am trying to add this and it does nothing, after I select the dll and click 'Add' just nothing happens. (Add reference is not adding this dll).
Just for example if I select some other dll and try to add, that works fine!
Could somebody please help me with this,
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.GenericAttributeProfile;
using Windows.Devices.Bluetooth.Advertisement;
Int16 uuid_count = 0;
BluetoothLEAdvertisement[] ble_adv = new BluetoothLEAdvertisement[5];
BluetoothLEAdvertisementReceivedEventArgs[] ble_received_adv = new BluetoothLEAdvertisementReceivedEventArgs[5];
BluetoothLEDevice bluetooth_LE_Device;
GattDeviceServicesResult result_service;// This line does not compile
//Error: CS0246 the type name 'GattDeviceServicesResult ' could not be found
// I am adding reference to "System.Runtime.WindowsRuntime" as mentioned in some solutions
// the reference does not seems to be added at first when I click add button, but I can see the reference dll being mentioned in solution explorer (assuming it's been added)
// using this to scan available devices
private void scann_ble()
{
var watcher = new BluetoothLEAdvertisementWatcher();
watcher.Received += Watcher_Received;
watcher.AdvertisementFilter.Advertisement.ServiceUuids.Clear();
watcher.Start();
while (true)
{
Thread.Sleep(10000);
break;
}
watcher.Stop();
}
// receiver event to collect addresses of available devices
private void Watcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
{
bool update_adv = true;
Int16 i = 0;
if(uuid_count < 5)
{
if (uuid_count > 0)
{
while (i < uuid_count)
{
if (ble_received_adv[i].BluetoothAddress == args.BluetoothAddress)
update_adv = false;
i++;
}
}
if(update_adv != false)
ble_received_adv[uuid_count++] = args;
}
}
// now connecting and checking available services
// as per "https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client"
private async void BLE_connect_button_Click(object sender, EventArgs e)
{
int i = 0;
i = BLE_device_grid_view.CurrentCell.RowIndex; // getting index from item selected in gridView
bluetooth_LE_Device = await BluetoothLEDevice.FromBluetoothAddressAsync(ble_received_adv[i].BluetoothAddress);
// Connection works fine, I can see it on my peripheral device
//get services - This is not working
result_service = bluetooth_LE_Device.GetGattServicesAsync();
if (result_service.Status == await GattCommunicationStatus.Success)
{
var services = result_service.Services;
// ...
}
}
I am using UwpDesktop package.
I had the same problem. My problem was solved after I changed the reference to windows.winmd from C:\Program Files (x86)\Windows Kits\10\UnionMetadata\windows.winmd to C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0\windows.winmd.
I'm using BLE 4.0 in a WinForm application and I'm working with Visual Studio 2017.
It is very likely that the directory 10.0.17763.0 doesn't exist on every computer, but you may look what versions of windows.winmd exists on your computer.

How to show erros occuring during installation of prerequesites

Using Wix 3.10
When installing .NET 4.6 on Windows 8.0, the Microsoft package returns an error since the computer is missing anothger kb by microsoft. That's ok so far, but I want to show this message from the NET-installer in my custom wpf-UI, but I didn't figured out what event will trigger.
In my viewmodel I have the current instance of the BootstrapperApplication and my first approach will not log anything:
internal MainViewModel(BootstrapperApplication model, Action<LogLevel, string> onLoggerAction, (....))
{
this.Model = model;
this.Model.DetectPackageComplete += this.DetectPackageComplete;
this.Model.DetectRelatedBundle += new EventHandler<DetectRelatedBundleEventArgs>(this.Model_DetectRelatedBundle);
this.Model.DetectPriorBundle += new EventHandler<DetectPriorBundleEventArgs>(this.Model_DetectPriorBundle);
this.Model.DetectRelatedMsiPackage += new EventHandler<DetectRelatedMsiPackageEventArgs>(this.Model_DetectRelatedMsiPackage);
this.Model.DetectTargetMsiPackage += new EventHandler<DetectTargetMsiPackageEventArgs>(this.Model_DetectTargetMsiPackage);
this.Model.Error += this.SetupError;
[...]
}
public void SetupError(object sender, ErrorEventArgs args)
{
this.onLoggerAction(LogLevel.Standard, string.Format("Error occured. Message: {0}", args.ErrorMessage));
this.onLoggerAction(LogLevel.Standard, string.Format("Error occured. ErrorCode: {0}", args.ErrorCode));
this.onLoggerAction(LogLevel.Standard, string.Format("Error occured. Type: {0}", args.ErrorType));
this.dispatcher.BeginInvoke((Action)(() => this.ShowErrorView(args)));
}
The log file shows the error:
[07D0:06D4][2016-05-09T09:16:36]i301: Applying execute package: Netfx4FullInternal, action: Install, path: C:\ProgramData\Package Cache\3049A85843EAF65E89E2336D5FE6E85E416797BE\NDP46-KB3045557-x86-x64-AllOS-ENU.exe, arguments: '"C:\ProgramData\Package Cache\3049A85843EAF65E89E2336D5FE6E85E416797BE\NDP46-KB3045557-x86-x64-AllOS-ENU.exe" /passive /norestart'
[07D0:06D4][2016-05-09T09:18:11]e000: Error 0x800713ec: Process returned error: 0x13ec
[07D0:06D4][2016-05-09T09:18:11]e000: Error 0x800713ec: Failed to execute EXE package.
[0928:09AC][2016-05-09T09:18:11]e000: Error 0x800713ec: Failed to configure per-machine EXE package
But how can I handle this error?
You already have the "/norestart" and "/passive" arguments in use, try using the "/log C:\pathtolog\yourlog.log" aswell so you can see what goes wrong.
Before shipping your installer you should have fixed all the errors, not display them all.
Imagine installing something and thousands of errors show up....

Resources