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

I created an application containing a ringtone, but how can I add it to iphone ringtones?

+4
source share
2 answers

Share iTunes files in your application and copy the ringtone file to the application’s document directory.

  • Install "Application supports iTunes file sharing" on YES in your info.plist file

  • If necessary, in the application, copy 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];

Now the user can access the ringtone via itunes and add it to their device ringtones.

+15
source

You can not. Apple does not release an API for exporting / recording ringtones to the operating system.

0
source

Source: https://habr.com/ru/post/1346252/


All Articles