Customize the AirDrop alert description in IOS

后端 未结 4 991
盖世英雄少女心
盖世英雄少女心 2021-02-02 14:19

I have the following code to send a URL through AirDrop:

NSString* selfUrlScheme = [[[[[[NSBundle mainBundle]
                                 


        
4条回答
  •  忘了有多久
    2021-02-02 14:49

    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.

提交回复
热议问题