Skip to content

Commit

Permalink
feat(core): expose methodName via CAPPluginCall (#7641)
Browse files Browse the repository at this point in the history
  • Loading branch information
robingenz authored Sep 27, 2024
1 parent 14e631c commit df109aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ios/Capacitor/Capacitor/CAPPluginCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ typedef void(^CAPPluginCallErrorHandler)(CAPPluginCallError *error);
@property (nonatomic, assign) BOOL isSaved DEPRECATED_MSG_ATTRIBUTE("Use 'keepAlive' instead.");
@property (nonatomic, assign) BOOL keepAlive;
@property (nonatomic, strong) NSString *callbackId;
@property (nonatomic, strong) NSString *methodName;
@property (nonatomic, strong) NSDictionary *options;
@property (nonatomic, copy) CAPPluginCallSuccessHandler successHandler;
@property (nonatomic, copy) CAPPluginCallErrorHandler errorHandler;

- (instancetype)initWithCallbackId:(NSString *)callbackId options:(NSDictionary *)options success:(CAPPluginCallSuccessHandler)success error:(CAPPluginCallErrorHandler)error;
- (instancetype)initWithCallbackId:(NSString *)callbackId options:(NSDictionary *)options success:(CAPPluginCallSuccessHandler)success error:(CAPPluginCallErrorHandler)error DEPRECATED_MSG_ATTRIBUTE("Specify the method name as well.");

- (instancetype)initWithCallbackId:(NSString *)callbackId methodName:(NSString *)methodName options:(NSDictionary *)options success:(CAPPluginCallSuccessHandler)success error:(CAPPluginCallErrorHandler)error;

- (void)save DEPRECATED_MSG_ATTRIBUTE("Use the 'keepAlive' property instead.");
@end
12 changes: 11 additions & 1 deletion ios/Capacitor/Capacitor/CAPPluginCall.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@

@implementation CAPPluginCall

- (instancetype)initWithCallbackId:(NSString *)callbackId options:(NSDictionary *)options success:(CAPPluginCallSuccessHandler) success error:(CAPPluginCallErrorHandler) error {
- (instancetype)initWithCallbackId:(NSString *)callbackId options:(NSDictionary *)options success:(CAPPluginCallSuccessHandler) success error:(CAPPluginCallErrorHandler) error __deprecated {
self.callbackId = callbackId;
self.methodName = @"";
self.options = options;
self.successHandler = success;
self.errorHandler = error;
return self;
}

- (instancetype)initWithCallbackId:(NSString *)callbackId methodName:(NSString *)methodName options:(NSDictionary *)options success:(CAPPluginCallSuccessHandler) success error:(CAPPluginCallErrorHandler) error {
self.callbackId = callbackId;
self.methodName = methodName;
self.options = options;
self.successHandler = success;
self.errorHandler = error;
Expand Down
2 changes: 1 addition & 1 deletion ios/Capacitor/Capacitor/CapacitorBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
dispatchQueue.async { [weak self] in
// let startTime = CFAbsoluteTimeGetCurrent()

let pluginCall = CAPPluginCall(callbackId: call.callbackId,
let pluginCall = CAPPluginCall(callbackId: call.callbackId, methodName: call.method,
options: JSTypes.coerceDictionaryToJSObject(call.options,
formattingDatesAsStrings: plugin.shouldStringifyDatesInCalls) ?? [:],
success: {(result: CAPPluginCallResult?, pluginCall: CAPPluginCall?) in
Expand Down

0 comments on commit df109aa

Please sign in to comment.