Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): cherrypick: expose methodName via CAPPluginCall (#7641) #7684

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?) -> Void in
Expand Down
Loading