Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3459952
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:10:14+00:00 2026-05-18T10:10:14+00:00

I have a method that get’s all devices that share a specific ID. Foreach

  • 0

I have a method that get’s all devices that share a specific ID. Foreach of those device UID’s, I am trying to send a APN (Apple Push Notification) using the easyAPN’s class.

The method that is having the problem is $apns->newMessage($id);

It seems to think I am not passing a valid integer for $id.

The $id is an array like so Array ( [0] => 1 )

I have also tried passing just the value of the array like so $apns->newMessage($id[0]).

No matter what I do.. I keep getting this error…

“Notice: TO id was not an integer. 1) Messages_model::send_apns -> File: sendMessage.php (line 28) 2) APNS::queueMessage -> File: messages_model.php (line 195) 3) APNS::_triggerError -> File: class_APNS.php (line 599)”

Here is my method… please let me know where I’ve gone wrong with the $id.

function send_apns($data)
{
    include 'apn_classes/class_DbConnect.php';
    include 'apn_classes/class_APNS.php';

    $message = new Messages_model();
    $db = new DbConnect();
    $db->show_errors();
    $apns = new APNS($db);

    //get uid's for aid
    $sql = "SELECT `devices`.`uid` FROM `devices` WHERE `devices`.`aid` = '".$data['target']."'";
    //echo $sql;
    $query = mysql_query($sql);
    if(mysql_num_rows($query))
    {
    while($uid_data = mysql_fetch_array($query))
        $uids[] = array(
            "uid" => $uid_data['uid']
        );
    }

    //make sure there is a uid
    if(!empty($uids))
    {
        //check the device apn pid
        foreach($uids as $uid)
        {
            $sql = "SELECT `apns_devices`.`pid` FROM `apns_devices` WHERE `apns_devices`.`deviceuid` = '".$uid['uid']."'";
            //echo "$sql";
            $query = mysql_query($sql);
            if(mysql_num_rows($query) > 0)
            {
                while($pid_data = mysql_fetch_array($query))
                {
                    $pids[] = array(
                        "pid" => $pid_data['pid'],
                    );

                    if(!empty($pids))
                    {
                        foreach ($pids as $pid)
                        {
                            $id = array($pid['pid']);
                            print_r($id);
                            //Send APN
                            $apns->newMessage($id[0]);
                            $apns->addMessageBadge(128);
                            $apns->addMessageAlert($data['message']);
                            $apns->addMessageSound('chime');
                            //$apns->addMessageCustom('acme2');
                            $apns->queueMessage();
                            $apns->processQueue();
                        }
                    }                   
                }
            }
        }

    }
    else 
    {
        echo "Device Does not Exist";
    }



}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:10:14+00:00Added an answer on May 18, 2026 at 10:10 am

    Try to convert $id to integer:

    ...
    foreach ($pids as $pid) {
      $id = intval($pid['pid']);
      print_r($id);
      //Send APN
      $apns->newMessage($id);
      ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JavaScript method that call JQuery.get() and i want to return value
Say you have a method that could potentially get stuck in an endless method-call
I have a method that accepts a sender and is called with a UIbutton.
I have a method that (sometimes) takes in a string in the format dddd
I have a method Get on a type MyType1 accepting a Func<MyType2, bool> as
I have several listboxes that get each of their data from a separate stored
I have a method in an object that is called from a number of
I have a Website class that has 3 get,set properties ID, Name, URL. For
I'm trying to save a PDF file to SQL Server and I already have
I have programmed with procedural style a lot before and in these few months

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.