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

  • SEARCH
  • Home
  • 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 9031667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:47:20+00:00 2026-06-16T07:47:20+00:00

Anyone know any good examples on how to setup a pjsip client to receive

  • 0

Anyone know any good examples on how to setup a pjsip client to receive messages.
I can send messages from the client using:

pjsua_im_send(sip_acc_id, &to, NULL, &msgbody, NULL, NULL);

to any number.

But I have no idea what to do to receive messages into the already registered sip account.

Any info would be greatly appreciated.

Note: I can only use pjsip and no other library.

Edit: Some new stuff I found:

http://trac.pjsip.org/repos/ticket/1070

http://www.pjsip.org/release/0.5.4/PJSIP-Dev-Guide.pdf (however all this document says about incoming msgs is this:

16.1.2 Receiving MESSAGE

Incoming MESSAGE requests outside any dialogs will be received by application
module.
Incoming MESSAGE requests inside a dialog will be notified to dialog usage via
on_tsx_state() callback of the dialog.

which still doesn’t shine much light on how to handle incoming messages.

http://www.ietf.org/rfc/rfc3261.txt

http://trac.pjsip.org/repos/wiki/SIP_Message_Buffer_Event

Edit2: I’ve been told that on_pager function needs to be used for this functionality. So I tried but still no success unfortunately.

Here is what I did:

/* Initialize application callbacks */
  app_config->cfg.cb.on_call_state = &on_call_state;
  app_config->cfg.cb.on_call_media_state = &on_call_media_state;
  app_config->cfg.cb.on_incoming_call = &on_incoming_call;
  app_config->cfg.cb.on_reg_state = &on_reg_state;
  app_config->cfg.cb.on_pager = &on_pager;

And the on_pager implementation:

static void on_pager(pjsua_call_id call_id, const pj_str_t *from, const pj_str_t *to, const pj_str_t *contact, const pj_str_t *mime_type, const pj_str_t *body) {

    NSLog(@"****************  on_pager called  **********************");
    AppDelegate *app = (AppDelegate *)[AppDelegate sharedApplication];

    pjsua_call_info ci;

    pjsua_call_get_info(call_id, &ci);

    PJ_UNUSED_ARG(call_id);
    PJ_UNUSED_ARG(to);
    PJ_UNUSED_ARG(contact);
    PJ_UNUSED_ARG(mime_type);

    [app ring];

    //PJ_LOG(3,(THIS_FILE, "MESSAGE from %.*s: %.*s (%.*s)", (int)from->slen, from->ptr, (int)text->slen, text->ptr, (int)mime_type->slen, mime_type->ptr));

    postMessageStateNotification(call_id, &ci);

}

I was expecting the application to call on_pager when a message is received but it didn’t.
on_incoming_call however, does get called.

  • 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-06-16T07:47:21+00:00Added an answer on June 16, 2026 at 7:47 am

    Turns out, what I did was correct, and it was just an issue with the server.
    Receiving msgs is now working!

    To sum it up, basically:

    when registering for sip:

     app_config->cfg.cb.on_pager = &on_pager;
    

    That will register for the on_pager() function to be called upon receiving an SMS.
    The rest is up to you what to do on inside that function.

    This is the function header:

    static void on_pager(pjsua_call_id call_id, const pj_str_t *from, const pj_str_t *to, const pj_str_t *contact, const pj_str_t *mime_type, const pj_str_t *body)
    

    I think everything is self explanatory for the function parameters, etc. Thanks everyone anyways for trying!

    And app_config is passed inside the pjsua_init() function.

    Also, in sipStartup() we register the NSNotification functions for iOS.

    /***** SIP ********/
    /* */
    - (BOOL)sipStartup
    {
        kSIPCallState         = @"CallState";
        kSIPRegState          = @"RegState";
        kSIPMwiInfo           = @"MWIInfo";
    
        if (_app_config.pool)
            return YES;
    
        self.networkActivityIndicatorVisible = YES;
    
        if (sip_startup(&_app_config) != PJ_SUCCESS)
        {
            self.networkActivityIndicatorVisible = NO;
            return NO;
        }
        self.networkActivityIndicatorVisible = NO;
    
        CTTelephonyNetworkInfo *phoneInfo = [[CTTelephonyNetworkInfo alloc] init];
        CTCarrier *phoneCarrier = [phoneInfo subscriberCellularProvider];
        NSLog(@"Carrier = %@", phoneCarrier);
    
        [self checkForConnection];
    
        NSTimer *timer;
        receiveCallTask = [[UIApplication sharedApplication]
                           beginBackgroundTaskWithExpirationHandler:^{
    
                           }];
    
        //timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(checkForConnection) userInfo:nil repeats:YES];
    
    
        /** Call management **/
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(processCallState:)
                                                     name: kSIPCallState object:nil];
    
        /** Registration management */
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(processRegState:)
                                                     name: kSIPRegState object:nil];
    
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(processMessageState:)
                                                     name:kSIPMwiInfo object:nil];
    
        return YES;
    }
    

    and processMessageState: is below:

    - (void)processMessageState:(NSNotification *)notification
    {
        NSLog(@"*****     processMessageState is called     *****");
        NSNumber *value = [[ notification userInfo] objectForKey:@"CallID"];
        pjsua_call_id callId = [value intValue];
    
        int state = [[[ notification userInfo] objectForKey:@"Event"] intValue];
    
        switch (state) {
            case PJSIP_EVENT_UNKNOWN:
                NSLog(@"unknown event");
                break;
            case PJSIP_EVENT_TIMER:
                NSLog(@"timer event");
                break;
            case PJSIP_EVENT_RX_MSG:
                NSLog(@"received --> rx_msg");
                break;
            case PJSIP_EVENT_TX_MSG:
                NSLog(@"tx_msg");
                break;
            case PJSIP_EVENT_TRANSPORT_ERROR:
                NSLog(@"msg transport error");
                break;
            case PJSIP_EVENT_TSX_STATE:
                NSLog(@"event tsx state");
                break;
            case PJSIP_EVENT_USER:
                NSLog(@"event user");
                break;
            default:
                NSLog(@"processMessageState was called");
                break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of any good websites on the upcoming Grand Central technology from
Does anyone know of any good examples of web based applications that uses one
Does anyone know of any good quantlib examples for Python? I cant seem to
Does anyone know of or having any good examples of how to use Entity
Does anyone know of any good examples of usage of HTML5 elements that are
does anyone know if there's any good online tutorial for building pivot tables using
Anyone know of any good examples of a simple BTree implementation in Javascript? I
Does anyone know any good resources with tasks or problems to get practice in
Trying to learn MVP pattern with C#... Does anyone know of any particularly good
does any one know of any good countdown timer's for flash which i can

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.