I have a react native app. I am trying to bridge react native with ios:
RCT_EXPORT_METHOD(getUserProfile:(RCTResponseSenderBlock)callback) {
Cosmote *cosmote = [[Cosmote alloc] init];
NSString * x;
NSString * str;
x = [cosmote getUserProfileWithCompletionHandler:^(NSString* string){string}]
callback(@[x]);
}
In Cosmote.swift I have the function:
@objc
open func getUserProfile(completionHandler: @escaping (_ s: String) -> ()) {
let x = UserDetailsManager.self;
x.getUserDetails(completionBlock: {data in
print("got user Details")
var json:String = "{\"data\": {\"guid\": \"\(data.guid)\", \"email\": \"\(data.email)\", \"username\": \"\(data.username)\", \"firstName\": \"\(data.firstname)\", \"lastName\": \"\(data.lastname)\", \"otePortalStatus\": \"\(data.otePortalStatus)\", \"otePortalisCorporate\": \"\(data.otePortalisCorporate)\", \"otePortalUserLevel\": \"\(data.otePortalUserLevel)\", \"otePortalAuthenticationLevel\": \"\(data.otePortalAuthenticationLevel)\", \"otePortalPIN\": \"\(data.otePortalPIN)\", \"otePortalEbppActivationDate\": \"\(data.otePortalEbppActivationDate)\", \"otePortalEbppEcareNumber\": \"\(data.otePortalEbppEcareNumber)\", \"otePortalEbppStatus\": \"\(data.otePortalEbppStatus)\", \"otegroupPasswordDate\": \"\(data.otegroupPasswordDate)\", \"otegroupStatus\": \"\(data.otegroupStatus)\", \"otegroupPasswordExpiration\": \"\(data.otegroupPasswordExpiration)\", \"otegroupPasswordReset\": \"\(data.otegroupPasswordReset)\", \"otegroupRegistrationDate\": \"\(data.otegroupRegistrationDate)\", \"otegroupAlternativeEmail\": \"\(data.otegroupAlternativeEmail)\", \"otegroupAlternativeMSISDN\": \"\(data.otegroupAlternativeMSISDN)\", \"imageURL\": \"\(data.imageURL)\"}}"
completionHandler(json);
}, onError: {_ in
print("did not get user Details")
completionHandler("{}");
})
}
At first function in line:
x = [cosmote getUserProfileWithCompletionHandler:^(NSString* string){string}]
I got the errors:
Assigning to 'NSString *__strong' from incompatible type 'void'
Incompatible block pointer types sending 'void (^)(NSString *__strong)' to parameter of type 'NSString * _Nonnull (^ _Nonnull)(NSString * _Nonnull __strong)'
How can I fix this?