My plugin:
#import <Foundation/Foundation.h>
@interface SampleClass:NSObject
(BOOL)isInstalledX: (NSString*) app;
(void)sendX: (NSString*) target;
@end
@implementation SampleClass
(BOOL)isInstalledX: (NSString*) app {
return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString: app]];
}
(void)sendX: (NSString*) target{
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:target]])
{
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:target]];
}
}
@end
NSString* convertString(const char* string)
{
return [NSString stringWithUTF8String: string];
}
extern "C"
{
bool isInstalled(const char* text){
return [SampleClass isInstalledX: convertString(text)];
}
void send(const char* url){
[SampleClass sendX: convertString(url)];
}
}
Every time i'm trying to build it returns IL2CPP Threadpool worker(54): EXC_BAD_ACCESS (code=1, address=0x10) on line return [NSString stringWithUTF8String: string];.
But when I remove send function the converion in isInstalled function is working.
Also C# code:
[DllImport ("__Internal")]
private static extern bool isInstalled(string text);
[DllImport ("__Internal")]
private static extern void send(string text);
...
if (!isInstalled("fb-messenger://"))
btn.gameObject.SetActive(false);
...
send("fb-messenger://share?link=" content);
CodePudding user response:
I changed the name of function send
to sendToApplication
and it's worked...