I create a ionic plugin with Plugman command.
(我用Plugman命令创建了一个离子插件。)
My plugin is: SayHello (我的插件是:SayHello)
This is the content of SayHello.js :
(这是SayHello.js的内容:)
var exec = require('cordova/exec');
exports.coolMethod = function (arg0, success, error) {
exec(success, error, 'SayHello', 'coolMethod', [arg0]);
};
And this is the content of SayHello.m :
(这是SayHello.m的内容:)
/********* SayHello.m Cordova Plugin Implementation *******/
#import <Cordova/CDV.h>
@interface SayHello : CDVPlugin {
// Member variables go here.
}
- (void)coolMethod:(CDVInvokedUrlCommand*)command;
@end
@implementation SayHello
- (void)coolMethod:(CDVInvokedUrlCommand*)command
{
NSLog(@"===============> Hello Seikida !");
CDVPluginResult* pluginResult = nil;
NSString* echo = [command.arguments objectAtIndex:0];
if (echo != nil && [echo length] > 0) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:echo];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
@end
I installed my custom plugin on my ionic project (ionic 4) :
(我在ionic项目(ionic 4)上安装了自定义插件:)
Everything is good (= I don't have error when I run my project on my devise) but I don't know how to call the coolMethod.
(一切都很好(=当我在自己的设备上运行项目时,我没有错误),但是我不知道如何调用coolMethod。)
To create my plugin, I follow this topic: Ionic Plugin Creation Using Plugman
(要创建我的插件,请遵循以下主题: 使用Plugman创建离子插件)
but they used a old ionic version (example: there is not Home.ts file on ionic 4).
(但他们使用的是旧的离子版本(例如:离子4上没有Home.ts文件)。)
Can you help me to understand how to use my plugin on the home.page.ts ?
(您可以帮助我了解如何在home.page.ts上使用我的插件吗?)
How import my plugin ? (如何导入我的插件?)
(And do you have a example?) ((你有例子吗?))
Thank you
(谢谢)
ask by seikida translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…