Has anyone faced issues with nativescript plugin calling android native code? - nativescript-angular

I am working on a nativescript plugin around a native Android SDK.
I have to subclass a native android abstract class
Given below is the way I did this: -
declare var com: any;
class MyCallBackClass extends com.xy.ab.mn.somesdk {
//com.xy.ab.mn.somesdk is from third party native android library and is an abstract class
//overridden methods and other variables
}
class MySDKClass {
myCallBack: any;
constructor() {
this.myCallBack = new MyCallBackClass()
}
}
All of this is done in a plugin. When I debug the plugin using the command npm run plugin.tscwatch, everything works fine. But when I pack the plugin into a .tgz file and use it in my app I am getting the following error: -
When I run the application, I am getting a runtime error as follows: -
System.err: TypeError: Cannot read property 'ab' of undefined
If anyone has faced the above issue and have a solution, please help.
Thanks in advance.

Related

Import org.openntf cannot be resolved

I have a Notes V11.0.1 designer client and configured a widget that imports the latest OpenNTF Domino API (downloaded from OpenNTF website) through an update site.
The plug-in is loaded in the designer
I created a new application and added the library to XSP Properties.
But when I create a simple Java class and want to import org.openntf.domino.*, I get an error:
package test;
import org.openntf.domino.*;
public class Test {
public static void test() {
Session session = null;
}
}
Error: the import org.openntf cannot be resolved.
Building the app does not solve the problem.
In the MANIFESST.MF I get the following error
Any idea why this goes wrong?
It's most likely that the default Target Platform in 9.0.1FP10 and newer (11.0.1 included) is broken: https://frostillic.us/blog/posts/2018/10/19/058650e080e352178525832b00519d2c

Xamarin.Android Cannot pull table from Azure database in Android 10 Q

I did read that because lack of support for Netcore 2.1 the
myItemsList = await App.MobileServiceAndroid.GetTable<MyTable>().ToListAsync();
does not currently work on Android, and there is a workaround to pass an HttpClientHandler() in the constructor of the MobileServiceClient, and so I did like this:
public static MobileServiceClient MobileServiceAndroid =
new MobileServiceClient(AppConstants.AZURE_PRODUCTION_WEB_API_URL, new HttpClientHandler());
But this is incomplete,its still not working, what exactly do I have to do to make this work, any guidance is much appreciated.
From my understanding, you are using a Forms/PCL project whereas the other solution was implementing this code inside their Android project.
For you, once you add using Xamarin.Android.Net; to the class, you should be able to just do this:
public static MobileServiceClient MobileServiceAndroid =
new MobileServiceClient(AppConstants.AZURE_PRODUCTION_WEB_API_URL, new AndroidClientHandler());
Most likely you might have issues getting that using statement, for that you will have to follow steps shown here, or customized for you in the following steps:
Add the Xamarin Forms project to all your projects.
Create an interface ICustomClientHandler in the Core project
using System;
using System.Net.Http;
namespace Test
{
public interface ICustomClientHandler
{
HttpClientHandler GetHandler();
}
}
Then create a CustomClientHandler in the Droid project, which will be the Android part of the dependency service that will help you retrieve the native AndroidClientHandler
using System.Net.Http;
using Xamarin.Android.Net;
using System.Runtime.CompilerServices;
using Xamarin.Forms;
using Test;
[assembly: Xamarin.Forms.Dependency(typeof(Test.Droid.CustomClientHandler))]
namespace Test.Droid
{
public class CustomClientHandler : ICustomClientHandler
{
public HttpClientHandler GetHandler()
{
return new AndroidClientHandler();
}
}
}
Implement an iOS version as well in a similar way, but it will instead return new HttpClientHandler();
Finally, use the code as shown, in your Core project:
var clientHandler = DependencyService.Get<ICustomClientHandler>().GetHandler();
public static MobileServiceClient MobileServiceAndroid =
new MobileServiceClient(AppConstants.AZURE_PRODUCTION_WEB_API_URL, clientHandler);

Implement gRPC in an iOS React Native app

As described in this issue, we can't implement a gRPC client using the Node implementation because "RN is not pure Node".
So I started working on an Objective-C implementation using the Native Modules.
[service postWithRequest:request handler:^(RequestConfirmation * _Nullable response, NSError * _Nullable error) {
if (response) {
// This prints correctly in my JS console
RCTLogInfo(#"%#", response.message);
// This generates an error, see below
resolve(response);
// This works
NSDictionary *formattedResponse = #{
#"id": response.id_p,
#"message": response.message
};
resolve(formattedResponse);
} else {
reject(#"error", #"An error occurred while saving", error);
}
}];
Error :
RCTJSONStringify() encountered the following error: Invalid type in JSON write (RequestConfirmation)
As you can see the problem is with the resolve method. I suppose React does not find any way to convert my proto message to JSON.
How can I keep the response as is and pass it to the resolve method ?
Then I can decode it in my JS code.
Thanks.
EDIT 1 :
RequestConfirmation is defined in my proto file like this :
message RequestConfirmation {
string id = 1;
string message = 2;
}
And then it is generated in Objective-C :
#interface RequestConfirmation : GPBMessage
#property(nonatomic, readwrite, copy, null_resettable) NSString *id_p;
#property(nonatomic, readwrite, copy, null_resettable) NSString *message;
#end
Maybe the following is a potential solution for this.
Improbable Engineering have coded:
grpc-web - Typescript/Javascript, browser or NodeJS!
Aside from the unfortunate naming, this appears not to be a mere fork of the official, C++-using, grpc-web project).
Quoting the Improbable project's own grpc-web-client page:
This library is intended for both JavaScript and TypeScript usage from either a browser or Node.js
The possible benefits of Improbable's version seem to be:
It doesn't appear to use native code (i.e. no C/C++/Java)
It can generate Typescript (therefore JavaScript) for Node.JS
So, maybe, we could get GRPC-on-RN working, when point No. 2 is coupled with a NodeJS-on-RN project such as rn-nodeify.
Please provide feedback, if you have any success with this.
At the time of writing, Improbable Engineering's gRP-Web can't be used with React Native.
Instead you must use React Native Native Modules and build native modules in Swift or Objective-C. Since React Native doesn't talk to Swift directly, you must create an Objective-C bridge if you choose to use Swift.
You will:
implement a gRPC client in the native language of your device,
export it using React Native's Native module framework
access the native module and its gRPC methods through React Native
Call those exported methods in React your Native code
The basic structure of this relationship is:
# Swift project
Reat Native <-> ObjC Bridge <-> Swift <-> gRPC
# Objective-C project
Reat Native <-> ObjC <-> gRPC
It's a pretty lengthy explanation of how to integrate these components. I've written a tutorial for Building a gPRC Client in React Native on iOS/Swift. I hope people find that useful.

Problems using an installclass in a web setup for a web site

I am trying to create a web setup for my web site, and I want to use an installer class to do some custom stuff. I am using VS 2010, and the web site and installer is .NET 3.5.
I have added reference to the installer class project output in the Install section under Custom Actions:
I have also set /targetdir="[TARGETDIR]/" on the CustomActionData for this action.
The InstallScript project is a standard class library (dll).
There is a public class that inherits from Installer class. It overrides the Install method as I have seen been done in several online examples:
using System.Collections;
using System.Windows.Forms;
namespace InstallScript
{
public class MyWebInstaller : System.Configuration.Install.Installer
{
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
var targetDir = Context.Parameters["targetdir"];
if(targetDir==null) targetDir = "No TARGETDIR!";
MessageBox.Show("TARGETDIR:\t" + targetDir);
}
}
}
I would think there should be shown a message box here som time during the install, but it seems like it is never called. No error is shown either. The setup just runs through as if this code was never called.
Anyone have idea of what is wrong?
OK, I found out what was missing.
You need to specify the class with the class attribute RunInstaller(true) for the setup to pick up and actually run the code.
So the class needs to be declared like this:
[System.ComponentModel.RunInstaller(true)]
public class MyWebInstaller : System.Configuration.Install.Installer
{
...

Secure in Playframework

I'm trying to install secure module in playframework, I tried with http://www.playframework.org/documentation/1.2.2/secure but Secure.class isn't found
import models.Task;
import play.mvc.Controller;
import play.mvc.With;
public class Application extends Controller {
#With(Secure.class)
public static void index() {
Please any help please
You have to add the module in the conf/dependencies.yml
It should look lie that :
# Application dependencies
require:
- play
- secure
Then you have to type the following command
play dependencies your_play_app
I have the following in dependencies.yml:
require:
- play -> secure
And I believe you have to protect the whole controller, using #With(Secure.class) before the class definition:
#With(Secure.class)
public class Application extends Controller {
...
}
As above, and if you're using Eclipse make sure you run play eclipsify to bring the Secure module (and it's classes) into your project.
Add the following dependency in your conf/dependencies.yml
require:
- play -> secure
Then, use the commands to install secure module
play dpes
If you use eclipse, remember the use the command after "play deps" command
play ec
This command will make the module visible in your eclipse

Resources