Hi all, Here I am struggling to incorporate the native IOS CALL function into unity. All I want is just to tab on a button and it make a phone call. I've heard about the plugins but I am not sure on how to build the plugins. Any help is much appreciated. T.Q. Best regards, Victor Yew
Thank you for your reply, synapsemassage. I know that's usually the case, but according to this page http://unity3d.com/support/documentation/Manual/Plugins.html it means more than that to me. I've searched all over the internet hoping to find one plugin which incorporates the function i mentioned above but with no luck. Perhaps, someone can actually guide me on how to build a native plugin from xcode.
yeah yeah I just found out just now. It does mentioned something I am looking for. I am about to try out. Thank you for the hints anyway.
@Victor, many thanks! We were put here on earth to make sure all the Unity devs can focus on their games and not on all the other silly stuff!
I found this a useful little tutorial on where to start with native plugins in OSX. Hopefully it'll give you some help with your calling issue: http://www.reigndesign.com/blog/unity-native-plugins-os-x/
could someone please elaborate more, I don't script.i need to make a call via a button but where would i put that piece of code and what else does it need thank you also if someone could point me in the direction of a plugin that would be cool
Hi , I was trying to do the same thing and make a call from a button in unity . I used Application.OpenURL("tel://myNumber") and it works fine . but what I need to do is to use symbols like # and * in the number string and if I use these symbols the rest of the string after these characters won't be send to tel app . I'll appreciate if someone can help me with this . thanks so much
just found my answer : http://stackoverflow.com/questions/4815785/initiate-a-phone-call-on-android-with-special-character Is this possible to directly call the number without having to click the dial button in the tell app? thanks
This is pretty wicked! In the stand alone player on my mac it opens up the Skyp ap, it did not dial my phone number on my mac though??? Not sure why?? But anyways this opens ideas Is it possible to make a dial screen in unity with GUI Texture buttons so you could dial a number in Unity and then have that number dial out? It seems like it could be done but not sure how that would be coded to work with GUI Texture buttons or a dialler ?
Appologies for bringing this thread back from the dead but does anyone know if this still works on iOS? I've tried Application.OpenURL("tel:+16048938347") and Application.OpenURL("tel://+16048938347") neither seem to do anything on iOS but both work on Andorid and WebGL
Please any body can reply in this, how to make phone call in iOS platform??? @RealWorld do you have any update in this?
Bumping this question. Tested on Unity 5.5 with iOS using Application.OpenURL("tel://1234567"), nothing happens. OpenURL works fine for all cases on Android and opens maps and websites on iOS, but not the phone dialer. Anyone have any suggestions?
Yes. I got this working. I have a iOS plugin script which is as follows: Code (CSharp): #import <CoreTelephony/CTTelephonyNetworkInfo.h> #import <CoreTelephony/CTCarrier.h> char* cStringCopy(const char* string) { if (string == NULL) return NULL; char* res = (char*)malloc(strlen(string) + 1); strcpy(res, string); return res; } // This takes a char* you get from Unity and converts it to an NSString* to use in your objective c code. You can mix c++ and objective c all in the same file. static NSString* CreateNSString(const char* string) { if (string != NULL) return [NSString stringWithUTF8String:string]; else return [NSString stringWithUTF8String:""]; } extern "C" { bool _canOpenURL(const char* cURL) { UIApplication *application = [UIApplication sharedApplication]; NSString *nsURL = CreateNSString(cURL); NSURL *URL = [NSURL URLWithString:nsURL]; BOOL canOpen = [application canOpenURL:URL]; if ( canOpen ) { if ( [nsURL hasPrefix:@"tel:"] ) { // Check if iOS Device supports phone calls CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *carrier = [netInfo subscriberCellularProvider]; NSString *mnc = [carrier mobileNetworkCode]; if (([mnc length] == 0) || ([mnc isEqualToString:@"65535"])) { return false; } else { return true; } } else return true; } return false; } } From C# you then need Code (CSharp): #if UNITY_IPHONE && !UNITY_EDITOR [DllImport ("__Internal")] private static extern bool _canOpenURL(string url); public static bool CanOpenURL(string url) { Debug.Log(string.Format("_canOpenURL({0})", url)); return _canOpenURL(url); } #endif #if UNITY_IPHONE && !UNITY_EDITOR if ( url.StartsWith("http") || CanOpenURL(url) ) { Application.OpenURL(url); return true; } return false; #endif The phone number should be in the format: +[countrycode][area code][number] So a UK number would be +448081234567 This works for me without problems but obviously, it doesn't work on a device which is incapable of making calls - so a phone without a SIM or an iPad will return false from canOpenURL. In that instance, I display a popup box with the phone number on it so the user can dial it however they want
This causes the telephone screen to open and show the correct number but it doesn't start the call anymore. One has to press the green phone button manually. Is there a way so that the call gets initiated without manually pressing the button? Many thanks..
Is there any way you can make a call from within an app, without leaving it and opening the phone app? I am trying to make a Kiosk-app that can make calls, but unfortunately it seems that it always needs to leave the app to make calls.Is there a workaround?
Ditto! I've been searching high and low for a similar method for my KITT A.I project where in an emergency situation we could instruct the AI to call emergency services onto the scene. Is there such a way to do this from a stand alone build that does not require launching an external application?
Thanks buddy. It solved my problem. However I am adding some more info to make it clearer and more modular for people. For people who want to make it modular to use for any mobile number, Follow the below Code : Note : This works for Unity Android Build. public string phoneURL; public TextMeshProUGUI empVehicleNum; public void OpenURL() { phoneURL = "tel://" + empVehicleNum.text; Application.OpenURL(phoneURL); } Use and define references as you please and follow the code above. Works like a charm!