Customize the AirDrop alert description in IOS Customize the AirDrop alert description in IOS ios ios

Customize the AirDrop alert description in IOS


You'll have to implement a class conforming to the UIActivityItemSource protocol. There is a very nice example here: https://developer.apple.com/LIBRARY/IOS/samplecode/sc2273/Introduction/Intro.html. Take a look at the APLCustomURLContainer in particular. After you implement your URL container class you can add it to the activity items along with a string (which will be your custom message)

MyURLContainer *container = [[MyURLContainer alloc] initWithURL:yourURL];NSString *message = @"Your message";UIActivityViewController activityController = [[UIActivityViewController alloc] initWithActivityItems:@[message, container] applicationActivities:nil];

EDIT:

I didn't have two phones to try that out at first so I tested only for Facebook and Twitter where it's working correctly, but for AirDrop I can confirm now (after some testing) that it is always using the relativeString of NSURL and even if you override that method of NSURL the sharing won't work so for AirDrop (the other activities such as FB are OK) it is not possible to change that message with the current SDK.


You need to follow the tutorial HERE. After the heading "A Quick Look at UIActivityViewController", i think thats exactly what you are looking for.

UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];[self presentViewController:controller animated:YES completion:nil];


Seems to me like it is using the description of the URL. I would try to subclass NSURL and override the description method to return something like @"a list". I didn't try it, but seems like it could work...

EDIT: I found this question that looks to be the same as yours and it has an accepted answer: Airdrop: making a custom URL scheme be less ugly for recipient