OneSignal 通知延迟
OneSignal Notifications delay
我在 android 上有一个 ionic 2 应用程序 运行,其中有一个提供数据的 wordpress 网站。我有使用 onesignal 的通知。问题是通知在其余 API 数据更新之前到达。该应用程序最多可能需要一分钟才能更新。有没有办法延迟单信号通知?或加速 wordpress json 数据?
你可能无法将 wp json 数据加速那么快,还有一些改进空间(以毫秒计)但没什么..只是需要时间。
如果你有编程知识,我会推荐这个:
- 覆盖该插件,删除为通知传递而发生的调用。
- 创建您自己的plugin/code,它只会根据 wp json 数据(成功)运行 通知传递代码。
我知道这没什么用,但是...:)
我也在找同样的东西。稍微修改了你的代码,它工作正常。
// Send OneSignal Push after some time delay.
add_filter('onesignal_send_notification', 'onesignal_delay_send', 10, 4);
function onesignal_delay_send($fields, $new_status, $old_status, $post) {
//delay
$delay = '+25 minutes';
//replace it with your timezone. Mine is UTC+05:30
$timezone = 0530;
$current_time = current_time('M d Y H:i:s e+$timezone');
$future_time = date( 'M d Y H:i:s e+$timezone', strtotime( $delay, strtotime( $current_time ) ) );
// Schedule the notification to be sent in the future
$fields['send_after'] = $future_time;
return $fields;
}
我在 android 上有一个 ionic 2 应用程序 运行,其中有一个提供数据的 wordpress 网站。我有使用 onesignal 的通知。问题是通知在其余 API 数据更新之前到达。该应用程序最多可能需要一分钟才能更新。有没有办法延迟单信号通知?或加速 wordpress json 数据?
你可能无法将 wp json 数据加速那么快,还有一些改进空间(以毫秒计)但没什么..只是需要时间。
如果你有编程知识,我会推荐这个:
- 覆盖该插件,删除为通知传递而发生的调用。
- 创建您自己的plugin/code,它只会根据 wp json 数据(成功)运行 通知传递代码。
我知道这没什么用,但是...:)
我也在找同样的东西。稍微修改了你的代码,它工作正常。
// Send OneSignal Push after some time delay.
add_filter('onesignal_send_notification', 'onesignal_delay_send', 10, 4);
function onesignal_delay_send($fields, $new_status, $old_status, $post) {
//delay
$delay = '+25 minutes';
//replace it with your timezone. Mine is UTC+05:30
$timezone = 0530;
$current_time = current_time('M d Y H:i:s e+$timezone');
$future_time = date( 'M d Y H:i:s e+$timezone', strtotime( $delay, strtotime( $current_time ) ) );
// Schedule the notification to be sent in the future
$fields['send_after'] = $future_time;
return $fields;
}