The SDLDialNumber RPC allows you make a phone call via the user's phone. Regardless of platform (Android or iOS), you must be sure that a device is connected via Bluetooth (even if using USB) for this RPC to work. If the phone is not connected via Bluetooth, you will receive a result of REJECTED from Core.
SDLDialNumber is an RPC that is usually restricted by OEMs. As a result, the OEM you are connecting to may limit app functionality if not approved for usage.
SDLDialNumber is a newer RPC, so there is a possibility that not all head units will support it. To find out if the RPC is supported by the head unit, check the system capability manager's hmiCapabilities.phoneCall property after the manager has been started successfully.
[self.sdlManager.systemCapabilityManager updateCapabilityType:SDLSystemCapabilityTypePhoneCall completionHandler:^(NSError * _Nullable error, SDLSystemCapabilityManager * _Nonnull systemCapabilityManager) { BOOL isDialNumberSupported = NO; if (error == nil) { isDialNumberSupported = systemCapabilityManager.phoneCapability.dialNumberEnabled.boolValue; } else { isDialNumberSupported = systemCapabilityManager.hmiCapabilities.phoneCall.boolValue; } <#If making phone calls is supported, send the `DialNumber` RPC#> }];
sdlManager.systemCapabilityManager.updateCapabilityType(.phoneCall) { (error, systemCapabilityManager) in var isDialNumberSupported = false if error == nil { isDialNumberSupported = systemCapabilityManager.phoneCapability?.dialNumberEnabled?.boolValue ?? false; } else { isDialNumberSupported = systemCapabilityManager.hmiCapabilities?.phoneCall?.boolValue ?? false } <#If making phone calls is supported, send the `DialNumber` RPC#> }
DialNumber strips all characters except for 0-9, *, #, ,, ;, and +.
SDLDialNumber *dialNumber = [[SDLDialNumber alloc] initWithNumber: @"1238675309"]; [self.sdlManager sendRequest:dialNumber withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { if (error != nil || ![response isKindOfClass:SDLDialNumberResponse.class]) { <#Encountered error sending DialNumber#> return; } SDLDialNumberResponse* dialNumber = (SDLDialNumberResponse *)response; SDLResult *resultCode = dialNumber.resultCode; if (!resultCode.success.boolValue) { if ([resultCode isEqualToEnum:SDLResultRejected]) { <#DialNumber was rejected. Either the call was sent and cancelled or there is no device connected#> } else if ([resultCode isEqualToEnum:SDLResultDisallowed]) { <#Your app is not allowed to use DialNumber#> } else { <#Some unknown error has occurred#> } return; } <#DialNumber successfully sent#> }];
let dialNumber = SDLDialNumber(number: "1238675309") sdlManager.send(request: dialNumber) { (request, response, error) in guard let response = response as? SDLDialNumberResponse, error == nil else { <#Encountered error sending DialNumber#> return } guard response?.success.boolValue == true else { switch response.resultCode { case .rejected: <#DialNumber was rejected. Either the call was sent and cancelled or there is no device connected#> case .disallowed: <#Your app is not allowed to use DialNumber#> default: <#Some unknown error has occurred#> } return } <#DialNumber successfully sent#> }
DialNumber has 3 possible results that you should expect: