Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a ringtone from an application to ringtones of iphone?

I have created an application included a ringtone, but how can i add it to ringtones of iphone?

like image 752
Ulvi Avatar asked Apr 01 '11 15:04

Ulvi


People also ask

How do I add my own ringtones to iPhone?

To do this, open the Settings app on your iPhone, then tap Sounds (also called Sounds & Haptics), then Ringtone. Your custom tones will appear at the top of the list, above the default Ringtones. Just tap on one to make it your ringtone.

How can I put ringtones on my iPhone without iTunes?

Here's how to set Ringtone in iPhone without iTunes:Open the Settings app on your iPhone. Tap on Sounds & Haptics. Then tap on Ringtone. Finally, under the Ringtone section, choose your custom ringtone.

Can I use audio file as ringtone iPhone?

How Do I Make an Audio File a Ringtone on My iPhone? To convert and use an audio file as your new ringtone, try the following from macOS or Windows: Install the latest version of iTunes. Select an audio file that is a maximum of 40 seconds long, otherwise, iTunes will not copy it to your phone.


1 Answers

Use iTunes file sharing in your app and copy the ringtone file to the app's documents directory.

  1. Set "Application supports iTunes file sharing" to YES in your info.plist

  2. Wherever appropriate in your app copy out the file with the code below:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyRingtone" ofType:@"m4r"];
NSData *mainBundleFile = [NSData dataWithContentsOfFile:filePath];

[[NSFileManager defaultManager] createFileAtPath:[documentsDirectory stringByAppendingPathComponent:@"MyRingtone.m4r"]
                                        contents:mainBundleFile 
                                      attributes:nil];

The user can now access the ringtone via itunes and add it to their device's ringtones.

like image 75
Michael Behan Avatar answered Oct 03 '22 05:10

Michael Behan