Skip to content

Adaptation for iOS 13 - [MPRemoteCommand add: target:] crash #40

@freedani

Description

@freedani

Example:

- (void)playAction:(MPRemoteCommand *)sender {
    // do something
}

- (void)func {
    MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
    // crash here
    [commandCenter.playCommand addTarget:self action:@selector(playAction:)];
}

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported action method signature. Must return MPRemoteCommandHandlerStatus or take a completion handler as the second argument.'

https://forums.developer.apple.com/thread/121540

Fix in iOS 13:

- (MPRemoteCommandHandlerStatus)playAction:(MPRemoteCommand *)sender {
    // do something
    return MPRemoteCommandHandlerStatusSuccess;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions