I found the error. The generated code adds “Async” to the service name string in the async versions of the method calls, which is not correct. Below, I’ve included a snippet from Android (which is correct) and a snippet from iOS to illustrate the difference.
Android
public static HashMap<String, String> upsertUser(String service, String authToken, String authSecret, String userId)
{
Object[] args = new Object[]{service, authToken, authSecret, userId};
return Backendless.CustomService.invoke( SERVICE_NAME, SERVICE_VERSION_NAME, "upsertUser", args, HashMap.class );
}
public static void upsertUserAsync(String service, String authToken, String authSecret, String userId, AsyncCallback<HashMap<String, String>> callback)
{
Object[] args = new Object[]{service, authToken, authSecret, userId};
Backendless.CustomService.invoke( SERVICE_NAME, SERVICE_VERSION_NAME, "upsertUser", args, HashMap.class, callback);
}
iOS
-(NSArray *)upsertUser:(NSString *)service authToken:(NSString *)authToken authSecret:(NSString *)authSecret userId:(NSString *)userId error:(Fault **)fault {
return [backendless.customService invoke:SERVICE_NAME serviceVersion:SERVICE_VERSION_NAME method:@"upsertUser" args:@[service,authToken,authSecret,userId] fault:fault];
}
-(void)upsertUser:(NSString *)service authToken:(NSString *)authToken authSecret:(NSString *)authSecret userId:(NSString *)userId response:(void(^)(NSArray *))responseBlock error:(void(^)(Fault *))errorBlock {
[backendless.customService invoke:SERVICE_NAME serviceVersion:SERVICE_VERSION_NAME method:@"upsertUserAsync" args:@[service,authToken,authSecret,userId] response:responseBlock error:errorBlock];
}
Notice that the string representing the service name doesn’t change in the Android code. You should update the code generation so others don’t face this issue in the future.
In addition, the iOS generated code provided the wrong return type, which caused further crashes after I changed the service name. It picked NSArray as the return type, but the service instead returns a JSON object (so in this case, an NSDictionary). After changing both the service name and the return type, I have the service working now.