【问题标题】:OneSignal Notifications delayOneSignal 通知延迟
【发布时间】:2017-06-12 04:37:54
【问题描述】:

我有一个在 android 上运行的 ionic 2 应用程序,它有一个提供数据的 wordpress 网站。我有使用 onesignal 的通知。问题是通知在其余 API 数据更新之前到达。该应用程序最多可能需要一分钟才能更新。有没有办法延迟 onesignal 通知?或加速wordpress json数据?

【问题讨论】:

  • 我在文档中发现有一个 send_after 字段,我正在插入一个带有必须使用插件的日期,例如 function onesignal_send_notification_filter($fields, $new_status, $old_status, $post) { date_default_timezone_set('UTC'); $newTime = date("M d Y H:i:s e+0000",strtotime(date("Y-m-d H:i:s")."+2 minutes")); $fields['send_after'] = (string)$newTime; return $fields; } 但这会阻止通知发送,有什么想法吗?跨度>

标签: android wordpress rest ionic-framework onesignal


【解决方案1】:

您可能无法将 wp json 数据加速那么多,还有一些改进的空间(以毫秒为单位)但没什么……只是需要时间。

如果你有编程知识,我会推荐这个:

  • 覆盖该插件,删除为通知传递而发生的调用。
  • 创建您自己的插件/代码,它只会在 UPON wp json 数据(成功)运行通知传递代码。

我知道这没什么帮助,但是... :)

【讨论】:

    【解决方案2】:

    我也在寻找同样的东西。稍微修改了你的代码,它工作正常。

    // 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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-11
      • 2012-06-04
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 2017-07-26
      • 1970-01-01
      相关资源
      最近更新 更多