Unable to get token using huawei_push - flutter

I have followed the steps in documentation to configure the huawei_push package in plugin.
I want to integrate push notification. I am getting error when i use this code
void _onTokenEvent(String event) {
token = event;
if (token != null) {
print("TokenEvent: " + token!);
}
}
void _onTokenError(PlatformException error) {
print("TokenErrorEvent: " + error.toString());
}
static Future<void> getToken() async {
try {
Push.enableLogger();
await Push.getToken("");
print('Huawei push token :: ${HosNotificationHelper.token} ');
Push.disableLogger();
} catch (e) {
print(e.toString());
print('THISIS EXCEPTION');
}
}
and error is below
I/HMSSDK_c(31657): The local secret is already in separate file mode.
E/HMSSDK_HMSPackageManager(31657): Failed to find HMS apk
I/HMSSDK_HMSBIInitializer(31657): Builder->biInitFlag :false
2
E/HMSSDK_HMSPackageManager(31657): Failed to find HMS apk
I/HMSSDK_HuaweiApi(31657): inner hms is empty,hms pkg name is com.huawei.hwid
I/HMSSDK_HuaweiApiManager(31657): sendRequest
I/HMSSDK_BaseHmsClient(31657): ====== HMSSDK version: 50300304 ======
I/HMSSDK_BaseHmsClient(31657): Enter connect, Connection Status: 1
I/HMSSDK_BaseHmsClient(31657): connect minVersion:30000000 packageName:com.huawei.hwid
I/HMSSDK_Util(31657): available exist: true
E/HMSSDK_HMSPackageManager(31657): Failed to find HMS apk
I/HMSSDK_AvailableAdapter(31657): HMS is not installed
I/HMSSDK_BaseHmsClient(31657): check available result: 1
I/HMSSDK_BaseHmsClient(31657): bindCoreService3.0 fail, start resolution now.
Please help

E/HMSSDK_HMSPackageManager(31657): Failed to find HMS apk
I/HMSSDK_AvailableAdapter(31657): HMS is not installed
This error indicates that the HMS Core is not installed on this device.
Therefore, you are advised to search for the HMS Core in the AppStore of the phone, install it, and try again.

Related

Use AspNetCore.SignalR.Client in Unity

I want to use SignalR in unity, I Added the Microsoft.AspNetCore.SignalR.Client nuget package in my solution. but in unity get the following error:
error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft'
for use SignalR in unity you can use bestHttp unity package , i used it , it's worked correctly
package link : link or Search bestHttp in UnityAssetStore
first needed Create connection :
using BestHTTP.SignalR;
Uri uri = new Uri("http://besthttpsignalr.azurewebsites.net/raw-connection/");
After we created the Connection, we can start to connect to the server by calling the Open() function on it:
signalRConnection.Open();
Handling general events:
OnConnected
signalRConnection.OnConnected += (con) => Debug.Log("Connected to the SignalR server!");
OnClosed
signalRConnection.OnClosed += (con) => Debug.Log("Connection Closed");
OnError
signalRConnection.OnError += (conn, err) => Debug.Log("Error: " + err);
for more info You can Read Document This link
hope that's Helpful:)

SSL Handshake fail when trying to download a file from an FTPS

What I'm doing?
I'm working on a iOS app which is going to download files from an FTPS server. For this purpose I'm using the library FilesProvider.
Error description
Until now I successfully achieve to login in the server, list files and search for files, but I'm getting the following error when trying to download one of the files:
File Provider <FilesProvider.FTPFileProvider: 0x283c23900> shouldDoOperation Copy with action Copying and destination file:///private/var/mobile/Containers/Data/Application/90AF4202-18C1-4A41-B461-4FB262FD39B9/tmp/B13A8110-C919-48E4-8BD9-E684929310C0.tmp
2020-05-27 14:35:39.372289+0200 MyApp[548:100799] [] nw_socket_handle_socket_event [C13:1] Socket SO_ERROR [54: Connection reset by peer]
2020-05-27 14:35:39.595959+0200 MyApp[548:99892] CFNetwork SSLHandshake failed (-9806)
2020-05-27 14:35:39.596380+0200 MyApp[548:99892] TCP Conn 0x28274f540 SSLHandshake failed (-9806)
File Provider <FilesProvider.FTPFileProvider: 0x283c23900> Failed for operation Copy with action Copying and destination file:///private/var/mobile/Containers/Data/Application/90AF4202-18C1-4A41-B461-4FB262FD39B9/tmp/B13A8110-C919-48E4-8BD9-E684929310C0.tmp
Throwing Error: Error Domain=NSOSStatusErrorDomain Code=-9806 "(null)" UserInfo={_kCFStreamErrorCodeKey=-9806, _kCFStreamErrorDomainKey=3}
FTPFileProvider is an object created with the library I've mention above that handles the FTP connection. That provider looks like:
guard let url = URL(string: "ftps://X.X.X.X") else { return } // I have to use an IP address instead of a domain
var provider = FTPFileProvider(baseURL: url, mode: .default, credential: credential, cache: .none)
provider.delegate = self
provider.fileOperationDelegate = self // This delegate is only for print the first line of the error
provider.serverTrustPolicy = .disableEvaluation
After creating the provider of the connection, I've been able to do login in the server, search some files and get the file list. I'm doing that with this function:
provider.searchFiles(path: remotePath, recursive: false, query: predicate, foundItemHandler: { (file) in print("File found with name: \(file.name)") }, completionHandler: { (list, error) in
if error != nil {
DispatchQueue.main.async {
onError(error!)
}
} else {
var files:[String] = []
for f in list {
(f.isRegularFile) ? files.append(f.name) : nil
}
DispatchQueue.main.async {
onSucess(files)
}
}
})
When running that search I get this warning:
2020-05-27 14:45:51.831812+0200 MyApp[555:102153] [] nw_socket_handle_socket_event [C4:1] Socket SO_ERROR [54: Connection reset by peer]
But I successfully get an output in onSuccess(files). The returned value for files is:
["20200527-093234-28346646454.pdf", "20200527-105409-28346646454.pdf"]
After that search, I try to download one of the files is when I get the error describe at the beginning of this post. For do the download I have the following function:
provider.copyItem(path: "\(remotePath)/\(file)", to: localPath.absoluteString, overwrite: true) { (error) in
if error != nil {
DispatchQueue.main.async {
onError(error!)
}
} else {
DispatchQueue.main.async {
onSuccess(localPath)
}
}
}
What I've try
As you could see above, the object who connect to the server has disabled the SSL certificate checks. That's why I can do the login and search for the files.
I've configure the Info.plist disabling ATS:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key> <!-- Because I wan't to allow everything -->
<true/>
<key>NSAllowsLocalNetworking</key> <!-- Because seems like library uses AVFoundation framework -->
<true/>
<key>NSAllowsArbitraryLoadsForMedia</key> <!-- Because I'm using a public IP instead a domain -->
<true/>
</dict>
Neither of that options works.
Some facts
Domain DNS entry is not going to be created for now. I can't do anything about this.
Server do have a valid SSL certificate.
I can successfully login, list files and search for files. (I just can't download)
I didn't try to upload a file. App isn't going to do it.
Questions
Why login, listing or searching files works but I get that error when trying to download?
Any idea on how to fix it? Any workaround?

Cannot start http server for devtools. Stop devtools / HTTP/1.1 404 Not Found

On startup I am getting the following error message shown in logcat.
org.chromium.chrome E/chromium: [ERROR:devtools_http_handler.cc(249)] Cannot start http server for devtools. Stop devtools.
I am running Chromium build 65.0.3317.0. This error does not happen on a previous version of Chromium, 54.0.2840.9, and the chromium devtools works fine. When I try to inspect a remote android device using devtools a blank tab opens with the error HTTP/1.1 404 Not Found.
I'll also attach the different in the files that are throwing the error.
Chromium 54 - devtools_http_handler.cc
void StartServerOnHandlerThread(
base::WeakPtr<DevToolsHttpHandler> handler,
base::Thread* thread,
DevToolsHttpHandler::ServerSocketFactory* server_socket_factory,
const base::FilePath& output_directory,
const base::FilePath& frontend_dir,
bool bundles_resources) {
DCHECK(thread->task_runner()->BelongsToCurrentThread());
ServerWrapper* server_wrapper = nullptr;
std::unique_ptr<net::ServerSocket> server_socket =
server_socket_factory->CreateForHttpServer();
std::unique_ptr<net::IPEndPoint> ip_address(new net::IPEndPoint);
if (server_socket) {
server_wrapper = new ServerWrapper(handler, std::move(server_socket),
frontend_dir, bundles_resources);
if (!output_directory.empty())
server_wrapper->WriteActivePortToUserProfile(output_directory);
if (server_wrapper->GetLocalAddress(ip_address.get()) != net::OK)
ip_address.reset();
} else {
ip_address.reset();
LOG(ERROR) << "Cannot start http server for devtools. Stop devtools.";
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&ServerStartedOnUI,
handler,
thread,
server_wrapper,
server_socket_factory,
base::Passed(&ip_address)));
}
Chromim 65 - devtools_http_handler.cc
void StartServerOnHandlerThread(
base::WeakPtr<DevToolsHttpHandler> handler,
std::unique_ptr<base::Thread> thread,
std::unique_ptr<DevToolsSocketFactory> socket_factory,
const base::FilePath& output_directory,
const base::FilePath& frontend_dir,
const std::string& browser_guid,
bool bundles_resources) {
DCHECK(thread->task_runner()->BelongsToCurrentThread());
std::unique_ptr<ServerWrapper> server_wrapper;
std::unique_ptr<net::ServerSocket> server_socket =
socket_factory->CreateForHttpServer();
std::unique_ptr<net::IPEndPoint> ip_address(new net::IPEndPoint);
if (server_socket) {
server_wrapper.reset(new ServerWrapper(handler, std::move(server_socket),
frontend_dir, bundles_resources));
if (server_wrapper->GetLocalAddress(ip_address.get()) != net::OK)
ip_address.reset();
} else {
ip_address.reset();
}
if (ip_address) {
std::string message = base::StringPrintf(
"\nDevTools listening on ws://%s%s\n", ip_address->ToString().c_str(),
browser_guid.c_str());
fprintf(stderr, "%s", message.c_str());
fflush(stderr);
// Write this port to a well-known file in the profile directory
// so Telemetry can pick it up.
if (!output_directory.empty()) {
base::FilePath path =
output_directory.Append(kDevToolsActivePortFileName);
std::string port_target_string = base::StringPrintf(
"%d\n%s", ip_address->port(), browser_guid.c_str());
if (base::WriteFile(path, port_target_string.c_str(),
static_cast<int>(port_target_string.length())) < 0) {
LOG(ERROR) << "Error writing DevTools active port to file";
}
}
} else {
LOG(ERROR) << "Cannot start http server for devtools. Stop devtools.";
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&ServerStartedOnUI, std::move(handler), thread.release(),
server_wrapper.release(), socket_factory.release(),
std::move(ip_address)));
}
You will notice that the 65 version is doing a boolean check on the ip_address value where as 54 only checks the server_socket.
I realize there is an unanswered post Cannot start http devtools but that is 3 months old with no response.

iOS: Error When accessing Async Storage: "No such file or directory"

I'm trying to access the async storage to get the array of podcasts. I add a podcast to the array and stringify it and try to persist it, and then I get the error:
Error: Failed to write value.Error Domain=NSCocoaErrorDomain Code=4
"The folder “a5a1507954e095ba66ba428410066532” doesn’t exist."
UserInfo={NSFilePath=/Users/clundberg/Library/Developer/CoreSimulator/Devices/F4A61A1A-9998-4C72-AD02-D6969E56990F/data/Containers/Data/Application/171D43CC-4BE5-4D64-8D30-C9582898A324/Documents/RCTAsyncLocalStorage_V1/a5a1507954e095ba66ba428410066532,
NSUserStringVariant=Folder, NSUnderlyingError=0x604002e5c080 {Error
Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}
Relevant code:
AsyncStorage.getItem("#podcasts")
.then(string => {
console.log(string)
const item = JSON.parse(string);
const podcasts = [...(item ? item : []), p];
console.log(podcasts)
return AsyncStorage.setItem("#podcasts", JSON.stringify(podcasts));
})
.catch(error => console.log(error));
Environment:
OS: macOS High Sierra 10.13.3
Node: 8.11.1
Yarn: Not Found
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Android Studio: Not Found
Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.53.0 => 0.53.0
AsyncStorage.getItem("#podcasts").then( (error,stringReturn) => {
console.log(stringReturn);
//the first parameter is the error checking the second one is the string you need i think
});
I'm not sure, but I think it's probably erroring where you return the setItem() call. If that's true, maybe try this...
AsyncStorage.getItem("#podcasts")
.then(string => {
console.log(string)
const item = JSON.parse(string);
const podcasts = [...(item ? item : []), p];
console.log(podcasts)
return podcasts;
})
.then(podcasts => AsyncStorage.setItem("#podcasts", JSON.stringify(podcasts))
.catch(error => console.log(error));
Another thought is that your simulator's AsyncStorage cache has become corrupted. The simulator stores the data on the actual file system. I'm just guessing here, but maybe the pointer to the directory has become invalid somehow. I would first try a very simple setItem() to see if it works. If it fails, then try restarting the app, clearing the cache, etc, etc. Make it all as fresh as possible.

C# Download File from HTTP File Directory getting 401 error or 403 error

I’m trying to download several files from a local network device:
http file directory
I want to write a code that will automatically download all those .avi files to my pc drive.
I have 2 problems:
Problem 1: AUTHENTICATING using WebClient class only.
If I use WebClient class only to connect, I get a 401 Unauthorized error.
Code:
try
{
using (WebClient myWebClient = new WebClient())
{
myWebClient.UseDefaultCredentials = false;
myWebClient.Credentials = new NetworkCredential("user", "pword");
String userName = "user";
String passWord = "pword";
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(userName + ":" + passWord));
myWebClient.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
Console.WriteLine("Header AUTHORIZATION: "+ myWebClient.Headers[HttpRequestHeader.Authorization].ToString());
// Download the Web resource and save it into the current filesystem folder.
Console.WriteLine("Start DL");
myWebClient.DownloadFile("http://192.168.2.72:81/sd/20170121/record000/P170121_000000_001006.avi", "P170121_000000_001006.avi");
Console.WriteLine("End DL");
}
}
catch(Exception ex)
{
Console.WriteLine("DOWNLOAD ERROR: " + ex.ToString());
}
Error Message: Failure to authenticate
401 Unauthorized Error
Problem 2: Was able to authenticate using WebProxy class but can’t download . Getting 403 Not found error.
Code:
try
{
using (WebClient myWebClient = new WebClient())
{
WebProxy wp = new WebProxy("http://192.168.2.72:81/sd/20170121/record000/",false);
wp.Credentials = new NetworkCredential("user","pword");
Console.WriteLine("Web Proxy: " + wp.Address);
myWebClient.UseDefaultCredentials = false;
myWebClient.Credentials = wp.Credentials;
myWebClient.Proxy = wp;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\"\n\n", filename, wp.Address);
// Download the Web resource and save it into the current filesystem folder.
Console.WriteLine("Start DL");
myWebClient.DownloadFile("http://192.168.2.72:81/sd/20170121/record000/P170121_000000_001006.avi", "P170121_000000_001006.avi");
Console.WriteLine("End DL");
}
}
catch(Exception ex)
{
Console.WriteLine("DOWNLOAD ERROR: " + ex.ToString());
}
Error Message: 403 Not Found
DOWNLOAD ERROR: System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
at System.Net.WebClient.DownloadFile(String address, String fileName)
at ConsoleApplication2.Program.Main(String[] args) in C:\Users\Gordon\documents\visual studio 2015\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs:line 139
Please help me identify if there are any mistakes in my code or is there a better way to submit credentials and download all the files.
Thanks in advance!
I'm not Dot Net developer, I'm just sharing my opinion.
In the second point you have mentioned that you are getting 403 which is the Http status code for Acces Denied. I feel your credentials are not valid or you don't have privilege to do the operation.