iosobjective-cuiactivityviewcontrollerimessage

Why does iMessages change the URL I pass to it via the UIActivityViewController?


my code is very simple, but there's a bug somewhere and I can't seem to figure this out.

Step 1:

// create an array that contains this url
NSArray *items = @[[NSURL URLWithString:@"https://danzafuerte33.as.me/YogaPrivate"]];

UIActivityViewController *shareController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];

[self.window.rootViewController presentViewController:shareController animated:true completion:nil];

Step 2: The activity view controller modal will show up, and one of the choices will be iMessages.

Step 3: Tap on iMessages -- notice that the correct url is shared -- so far so good

Step 4: Tap cancel on the iMessages modal window, the UIActivityViewController should still be visible

Step 5: Tap on iMessages again, the url is changed to https://app.acuityscheduling.com/schedule.php?owner=12808744 which is not the right url!

Why on earth is this happening the second time iMessages opens this link, is this an iMessages bug?


Solution

  • When the url is passed to iMessages, it retrieves the web site in order to render a preview.

    At the top of the page returned is:

    <link rel="canonical" href="https://app.acuityscheduling.com/schedule.php?owner=12808744">
    

    This says that the canonical link for this page is https://app.acuityscheduling.com/schedule.php?owner=12808744, and so the activity item is updated with this, preferred, url for the page.