|
|
Classification: |
C++ |
Category: |
Messaging |
Created: |
10/18/2001 |
Modified: |
11/07/2001 |
Number: |
FAQ-0743 |
Platform: |
Symbian OS v6.0 |
|
Question: How can I create an SMS and send it immediately?
Answer: This is quite a common scenario when, for example, you are developing a wireless game. The Nokia 9210 SDK includes a sample
application called Treasure and this is a good starting point. However, one area where the example (correct at 18/10/01) does
not take things far enough for some developers is with sending the SMS immediately. Instead the example puts the message in
the Drafts folder ready for the user to send manually.
You can change this behaviour in two steps:
1. Create the SMS in the Outbox not Drafts 2. Use the Scheduled Sending feature of Symbian OS Messaging to send the message immediately (or as soon as is possible -
for example once the phone is in an area with network reception)
To put it in another folder you can use a second overload of CreateMessageL(), i.e.:
IMPORT_C void CreateMessageL(TMsvId aId);
Using the above you can specify KMsvGlobalOutBoxIndexEntryId as the location to store your message.
To schedule the SMS for sending 'now' you can use the following code. Once this has completed the System Agent takes over
and re-schedules for you in the event of any problems, etc.). You would use this just after iSendAs->SaveMessageL(ETrue);
// // Take care of sending the SMS now (schedule it to send now) // TMsvEntry entry(iSendAs->ClientMtm().Entry().Entry()); entry.iDate.HomeTime(); entry.SetOffPeak(EFalse); iSendAs->ClientMtm().Entry().ChangeL(entry);
CMsvEntrySelection* sel = new(ELeave) CMsvEntrySelection; CleanupStack::PushL(sel); sel->AppendL(entry.Id());
CMsvOperation* operation = NULL; CleanupStack::PushL(operation);
CMsvOperationWait* waiter=CMsvOperationWait::NewLC(); TBuf8<1> dummy; operation=iSmsMtm->InvokeAsyncFunctionL(ESmsMtmCommandScheduleCopy,*sel,dummy,waiter->iStatus); waiter->Start(); CActiveScheduler::Start();
CleanupStack::PopAndDestroy(3); // waiter, operation, sel
|
|
|