【发布时间】:2022-01-19 13:54:35
【问题描述】:
我有一个颤振应用程序,它使用 Pusher 光束来接收消息,它在 Android 中一切正常,在 IOS 中,当我在调试模式下运行应用程序时,它像往常一样正常接收事件,即使应用程序处于前台但当我在 xcode 中以发布模式运行它它会停止在后台接收事件,并且一旦将应用程序恢复到前台,它就会接收在应用程序处于后台时发送的所有事件这是我的代码将它放在家庭中屏幕:
PusherOptions options = PusherOptions(
auth: PusherAuth(
url + 'broadcasting/auth',
headers: {
'Authorization': 'Bearer $token',
},
),
cluster: configurationModel.pusherAppCluster,
);
PusherClient pusher = PusherClient(
configurationModel.pusherAppKey,
options,
autoConnect: false
);
pusher.connect();
// Subscribe to a private channel
Channel channel = pusher.subscribe(pusherChannel);
// Bind to listen for events called "order-status-updated" sent to "private-orders" channel
channel.bind(pusherEvent, (PusherEvent event) {
_showNotificationCustomSound();
});
【问题讨论】:
-
你用的是哪个包?
-
这听起来是对的。 iOS 应用程序在后台时无法保持网络连接。在 Xcode 下运行时,行为会有所不同,因为调试过程会阻止应用真正挂起。
-
@croxx5f 我正在使用 pusher_client 2.0
标签: ios flutter dart pusher pusherswift