Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jacopocappelli89

    (@jacopocappelli89)

    Hi Tanvirul,
    thanks for the quick reply, i do the registration with error and debug:

    Thanks,
    Jacopo

    Thread Starter jacopocappelli89

    (@jacopocappelli89)

    Closed!

    Change this file: wp-content/plugins/all-push-notification/pushnotification/class-pushnotification-ios.php

    with this:
    foreach ($devices as $device) {
    error_log(“device:”.$device);
    // Build the binary notification
    $msg = chr(0) . pack(‘n’, 32) . pack(‘H*’, $device) . pack(‘n’, strlen($payload)) . $payload;

    //Send it to the server
    $results[] = fwrite($fp, $msg, strlen($msg));
    if(!$result){
    fclose($fp);
    sleep(2);
    if($send_via_production==”yes”){
    $fp = stream_socket_client(‘ssl://gateway.push.apple.com:2195’,$err,$errstr,60,STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT,$ctx);
    }else{
    $fp = stream_socket_client(‘ssl://gateway.sandbox.push.apple.com:2195’,$err,$errstr,60,STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
    }
    }else{
    //Insert msgs into pushnotification log table
    global $wpdb;
    $blogtime = current_time( ‘mysql’ );
    $all_pushnotification_logs = $wpdb->prefix . ‘all_pushnotification_logs’;
    $wpdb->insert($all_pushnotification_logs,array(‘push_title’ => $msg_title,’push_message’ => $message_text,’push_sent’ => 1,’push_send_date’ => $blogtime,’devicetoken_id’ =>$device),array(‘%s’,’%s’,’%d’,’%s’,’%s’));
    }
    }

    If you have problem on iOS notification:

    Change this file: wp-content/plugins/all-push-notification/pushnotification/class-pushnotification-ios.php

    with this:
    foreach ($devices as $device) {
    error_log(“device:”.$device);
    // Build the binary notification
    $msg = chr(0) . pack(‘n’, 32) . pack(‘H*’, $device) . pack(‘n’, strlen($payload)) . $payload;

    //Send it to the server
    $results[] = fwrite($fp, $msg, strlen($msg));
    if(!$result){
    fclose($fp);
    sleep(2);
    if($send_via_production==”yes”){
    $fp = stream_socket_client(‘ssl://gateway.push.apple.com:2195’,$err,$errstr,60,STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT,$ctx);
    }else{
    $fp = stream_socket_client(‘ssl://gateway.sandbox.push.apple.com:2195’,$err,$errstr,60,STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
    }
    }else{
    //Insert msgs into pushnotification log table
    global $wpdb;
    $blogtime = current_time( ‘mysql’ );
    $all_pushnotification_logs = $wpdb->prefix . ‘all_pushnotification_logs’;
    $wpdb->insert($all_pushnotification_logs,array(‘push_title’ => $msg_title,’push_message’ => $message_text,’push_sent’ => 1,’push_send_date’ => $blogtime,’devicetoken_id’ =>$device),array(‘%s’,’%s’,’%d’,’%s’,’%s’));
    }
    }

Viewing 3 replies - 1 through 3 (of 3 total)