Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Receiving a Message

Objective

This topic shows how to receive an SMS message.

Requirements

To receive an SMS message, an application needs to:

  1. Register for SMS notifications.
  2. Check notify events for SMS events.
  3. Get the message.
  4. At some point, the application must release the message.

Event handling

The application must process notify events. Each notification event must be checked to see if the event is for SMS or EMS. The application can register for SMS notify events; or, the MIF can specify the application is to receive AEECLSID_SMSNOTIFIER events.

Example

Register for SMS notifications:

 // Register for Text and EMS messages
 ISHELL_RegisterNotify(pMe->a.m_pIShell, AEECLSID_SAMPLESMS, AEECLSID_SMSNOTIFIER,
      (AEESMS_TYPE_TEXT << 16) | NMASK_SMS_TYPE);
 ISHELL_RegisterNotify(pMe->a.m_pIShell, AEECLSID_SAMPLESMS, AEECLSID_SMSNOTIFIER,
      (AEESMS_TYPE_EMS << 16) | NMASK_SMS_TYPE);

When the application receives a notify event, check for an SMS event:

 case EVT_NOTIFY:
{
   // Cast dwParam as an AEENotify structure
   AEENotify *temp = (AEENotify *) dwParam;

   // Check for proper mask and type of notify event
   if (AEECLSID_SMSNOTIFIER == temp->cls &&
       ( (((AEESMS_TYPE_TEXT << 16)|NMASK_SMS_TYPE) == temp->dwMask) ||
         (((AEESMS_TYPE_EMS << 16) |NMASK_SMS_TYPE) == temp->dwMask) ))
   {
         
         // Get the message 
         
         return(TRUE);
   }

   // We received an EVT_NOTIFY that we do not intend to handle
   return FALSE;
}

Get the message. The messageid parameter in the receive message call is the dwParm parameter from the notify event.

 if (SUCCESS == ISMS_ReceiveMsg(pMe->m_pISMS, messageID, &pMe->m_pISMSMsgRcv)) 
 {
    // The application my retrieve the message parameters, or perform other
    // operations on the message and then may
    // store the message in SMS Storage
    ISMSMSG_GetOpt(pMe->m_pISMSMsgRcv,...);

    // see the topic on storing a message...
 }

After being processed the message must be released.

 if (pMe->m_pISMSMsgRcv) {
    ISMSMSG_Release(pMe->m_pISMSMsgRcv);
    pMe->m_pISMSMsgRcv = NULL;
 }