Keep music app alive in background, iOS and Android?

后端 未结 2 1976
后悔当初
后悔当初 2021-01-12 11:02

I am building a music playing app using Flutter. It helps me as a single developer to build an app once for both platforms. However there are a few hiccups I have hit on bot

2条回答
  •  孤独总比滥情好
    2021-01-12 11:02

    Solution is a one liner on the iOS Side.

    You need this code in either your first view controller's init or viewDidLoad method:

    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

    https://stackoverflow.com/a/9721032/6024667

    Swift 3 UIApplication.sharedApplication().beginReceivingRemoteControlEvents()

    Swift 4 UIApplication.shared.beginReceivingRemoteControlEvents()

    Add this code to AppDelegate.m/AppDelegate.swift inside your iOS/Runner directory, just before the return.

提交回复
热议问题