Sending push notifications to Android devices using Parse - c#

I find the parse documentation is little confusing when it comes to Android. I am sending notifications using Parse from a .NET background service. The service is calling Parse REST API
Install the device with deviceToken and deviceType
Send push notification to device once the previous step is successful.
This works beautifully with iOS device
POST: 1/push
{
"deviceToken": "<big device token>",
"deviceType": "android",
"channels" : []
}
This says
{
code: 114
error: "deviceToken may not be set for deviceType android"
}
the documentation says, we need to have a unique installationId for Android device install uploads. How do I do this from backend? Which API should be used to get installation Id?

This is how you get the installation ID :
ParseInstallation.getCurrentInstallation().getInstallationId()
(Class Reference)

What I understand, Parse doesn't support android device installations using REST API; it supports from client side SDK.
https://www.parse.com/questions/android-device-installation-via-rest

Related

.NET MAUI (iOS) : MidiPort.Send is obsolete since iOS 14 - no other way for sending MIDI via CoreMIDI on iOS available?

I am using .NET MAUI, but focusing only on iOS right now, I cannot find a way (an API) to send MIDI on iOS.
Naturally it would be CoreMidi and the MidiPort class using its Send method, but as the source states, since iOS 14 its not supported any more
[ObsoletedOSPlatform("macos11.0")]
[ObsoletedOSPlatform("ios14.0")]
[SupportedOSPlatform("ios")]
[SupportedOSPlatform("maccatalyst")]
[SupportedOSPlatform("macos")]
[UnsupportedOSPlatform("macos11.0")]
[UnsupportedOSPlatform("ios14.0")]
public MidiError Send(MidiEndpoint endpoint, MidiPacket[] packets);
I can retrieve a valid MidiDevice, MidiEntity and MidiEndpoint(which are related to the CoreMidi "Network" session / port), but after that I am stuck - theoretically I got all to call MidiPort.Send(see : https://learn.microsoft.com/en-us/dotnet/api/coremidi.midiport.send), but the method is not available in iOS 16.
And by the way, that is not the only obsolete CoreMIDI API - the Xamarin iOS MIDI sample has same issues : https://learn.microsoft.com/en-us/samples/xamarin/ios-samples/miditest/.
Any Ideas?
cheers
Ayaphi

I can't upload user face template in device (SpeedFace-V4L)

I am using the ZKteco device (speedFace-V4L) with the ZKFace VX5.8 facial algo.
I want to download and upload the users faces templates, but I can't do it.
If I try to download the face template (from device to software) it works, but the opposite does not work, it downloads all other information without a face template.
I debugged this and found the error code is -103, according to the documentation which means device send back error of face version error
I tested the official demo with this device, and it still doesn't work!
I'm using GetUserFaceStr(int dwMachineNumber, string dwEnrollNumber, int dwFaceIndex, ref string TmpData, ref int TmpLength); function to get user informations and SetUserFaceStr(int dwMachineNumber, string dwEnrollNumber, int dwFaceIndex, string TmpData, int TmpLength) to set it
I forgot to say that the functions are working fine with the MB2000 device.
How can i solve this please.
Device: SpeedFace V4L
Face algo: ZKFace VX5.8
SDK: Standalone SDK-6.3.1.43
Language: C#, WPF
I had the same problem just a few days. We contacted ZKteco support and this the solution:
The Standalone SDK is not fully compatible with ZkTeco Visible Light Series devices and you have to contact ZKteco Sales to request the Push SDK which is in deed a communication protocol Http based so they will give access to the Api.
The ZkTeco new devices have http server like embeded. Also you have to pay for that Push SDK.
But with it you will be able to download user faces and upload user faces to SpeedFace v4L devices via TCP IP.

Uploading an image to Microsoft Cognitive Services?

I am trying to post an image to the Computer Vision API of Microsoft Cognitive Services. It requires me to upload the image as an url. I have the uploaded image by the user with an URI like http://localhost:9000/content/8a684db8?file=IMG-20160503-WA0002.jpg on my local pc. I tried the obvious but that doesn't work. How to pass the image to their API?
They also mention I can post the image as a raw binary but I am unable to get how to get going.
PS: You can get the subscription keys using the free subscriptions if you want to test it for some other cases.
localhost is 127.0.0.1, e.g. your PC when accessing from your PC. You should pass external IP of your PC in the internet
Well I was able to get a solution. Didn't post my answer sorry.
Microsoft Computer Vision Documentation This shows how to call their API's using the nuget Microsoft.ProjectOxford.Vision.The below code uploads and analyzes a locally stored image to the analyze endpoint of the Computer Vision API service.
using Microsoft.ProjectOxford.Vision;
using Microsoft.ProjectOxford.Vision.Contract;
private async Task<AnalysisResult> UploadAndAnalyzeImage(string imageFilePath)
{
//
// Create Project Oxford Computer Vision API Service client
//
VisionServiceClient VisionServiceClient = new VisionServiceClient(SubscriptionKey);
Log("VisionServiceClient is created");
using (Stream imageFileStream = File.OpenRead(imageFilePath))
{
//
// Analyze the image for all visual features
//
Log("Calling VisionServiceClient.AnalyzeImageAsync()...");
VisualFeature[] visualFeatures = new VisualFeature[] { VisualFeature.Adult, VisualFeature.Categories, VisualFeature.Color, VisualFeature.Description, VisualFeature.Faces, VisualFeature.ImageType, VisualFeature.Tags };
AnalysisResult analysisResult = await VisionServiceClient.AnalyzeImageAsync(imageFileStream, visualFeatures);
return analysisResult;
}
}
On this Git Repository you can see some samples.Here you also get how you can handle client errors and exceptions.

Can't instantiate a new GattDeviceService

I'm new to Bluetooth LE, and I'm trying to write to a Bluetooth HID device.
I'm using Visual Studios 2015 and am building a WPF application.
currently my code looks like this:
var hidDevices = await DeviceInformation
.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(
GattServiceUuids.HumanInterfaceDevice));
GattDeviceService bleDevice = await GattDeviceService.FromIdAsync(hidDevices[0].Id);
I have some code after, but my code stops right after I try to create a new GattDeviceService.
I know hidDevices[0] is occupied, but the ID generated shows up like this:
\\?/BTHLEDEVICE#{00001812-xxxx-xxxx-xxxx-xxxxxxxxxxxx}_Dev_VID&.........
I'm curious if that is normal.
GATT API does not allow you access HID Services.
I found information about your problems:
Bluetooth GATT—Windows.Device.Bluetooth.Gatt
The API lets Windows Store app developers implement GATT client
profiles for collecting data from low energy (LE) sensors.
A Bluetooth 4.0 radio is required to use the GATT API.
The GATT API prevents access to the following in-box and invalid
services:
(Bluetooth SIG name) 0x1812 HID Over GATT Service
For more informations: https://msdn.microsoft.com/en-us/library/windows/apps/bg182882.aspx

How can I connect to a Server Side USB (HID) Device from within an ASP.NET Application?

I'm trying to write my own controller for a USB device instead of using the SDK that comes with the product (I feel the sdk is sub-par).
The USB Device is plugged into the SAME SERVER that this application is running on.
So I decided to head over to Nuget and grab the HidLibrary
PM> Install-Package hidlibrary
and I proceeded to follow the example found on GitHub.
First I went into my control panel to verify the VendorID and the ProductID
And I dropped it into my code.
Then I set a breakpoint on the line that grabs the device, but unfortunately it always comes back null.
using HidLibrary;
public class MyController : ApiController
{
private const int VendorId = 0x0BC7;
private const int ProductId = 0x0001;
private static HidDevice _device;
// POST api/<controller>
public string Post(CommandModel command)
{
_device = HidDevices.Enumerate(VendorId, ProductId).FirstOrDefault();
if (_device != null)
{
// getting here means the device exists
}
else
{
// ending up here means the device doesn't exist
throw new Exception("device not connected");
}
return null;
}
I'm hoping it's something silly, and not some deal-breaking permissions issue regarding connecting to a USB device directly from an IIS worker.
Despite your hopes to be something silly, it is not. You have some deal-breaking permission issues. If you will browse Mike O'Brien's code from GitHub of the Hid Library you will see that it calls Win32 API functions located in: kernel32.dll, setupapi.dll, user32.dll, hid.dll (Native.cs).
The enumeration itself it's done through setupapi.dll functions. It browse all the installed devices and filters what it's need it.
So... I think it's a security issue to execute kernel32.dll code directly from a web-app in IIS with anonymous authentication, don't you?
If you really need to communicate with that HID (who knows maybe it's a temperature sensor, or something else) I would do a separate Windows service and the IIS hosted web app would communication through WCF with this service. This service would like a proxy.
Put the same code in a console application and run it. That will help you verify if it's your code or environment.
If it's environment, try using Process Monitor to see if there are any hidden access errors. Also try enumerating all devices, not just looking for the one device you're after, just to see if you can do it in ASP.NET.
#Chase, unless this is an experiment - it is best not to attempt connecting to a device from IIS process. [It's a Pandora's box if you start down this path].
Best way to do this is to have another (WCF) service as proxy to the device and expose just what you need out of the service, hook it up with your app. Feel free to ask for an example if you think that would help.
I +1 #garzanti.

Categories

Resources