Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I have checked my code by running from URL it's working fine while I am trying from the browser. but it's not working with the curl code and I can not find the solution. curl_error gives nothing. I have read that "devices won't always connect to the same public IP address for notifications. " but what is the solution for that Please suggest what is wrong with the curl code/ other issues possibilities.
curl_error
Here is the curl code
$ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, BASE_URL .'api-v2/admin_notification_cron.php'); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); $result = curl_exec($ch ); curl_close( $ch );
And admin_notification_cron.php file fetch data from the database and call the sendNotification function after fetching 20 data from database every 1 Minuit
admin_notification_cron.php
Below is the sendNotification function code:
sendNotification
function sendToIphone($deviceToken, $data) { $data['push_image'] = (($data['push_image']!='')?PHOTO_URL.'push/'.$data['push_image']:''); $passphrase = ''; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns-dev-cert.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', ''); $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); $type = ($data['type']!='')?$data['type']:'0'; if ($data['message']=='add_job' || $data['message']=='process') { //$sound = 'newrequest.mp3'; $sound = 'default'; } else { $sound = 'default'; } $body['aps'] = array( 'alert' => stripslashes($final_message), 'title' => APP_TITLE, 'job_id' => $data['job_id'], 'user_id' => $data['user_id'], 'created'=> $data['created'], 'type'=> $type, 'sound' => $sound, "mutable-content"=> 1, "category"=> "rich-apns", "image-url"=> $data['push_image'], 'badge' => REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
There are some thumb rules to implement APNS.
APNS
Curl connection should be closed after delivered notification.
notification
You have to wait until your previous notification was not delivered.
If you are executing all code in loop then some notification delivered and rest of notification will be discarded.
To fix your issue you have put some delay between two notification triggered or fire notificationafter previous notification delivered.
OR
You can use Third party Notification tools
FCM
OneSignal
It will manage automatically.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.