PUSH

阅读更多
1.WAP更像因特网,是一个内容丰富的站点,用户如何找到自己喜欢的站点,如何在一个站点中找到自己喜欢的业务,往往需要花上很长的一段时间。而WAP PUSH可以将某一站点或某一业务的链接通过短信发送到支持WAP PUSH功能的手机上,这样您只需要阅读这条短信,打开短信中的链接,就可以直接访问业务了。因此,WAP PUSH实现了短信和WAP业务的结合,节省了您寻找业务的时间,方便您直接找到并使用自己喜欢的业务。

 哪些手机支持WAP PUSH?

  目前支持这一功能的手机有:诺基亚、索尼爱立信、西门子的全部GPRS手机,摩托罗拉一般都支持。详细情况可以咨询您的手机制造商。

  如果您的手机不支持WAP PUSH,将会收到一条内容为乱码的信息。

2.

 

我解决了这个问题,但可能运营商的网关有很大关系,不一定到处通用,大家可以试试,在北京是可以的。
有些相关的文档可以参考:
http://www.cnblogs.com/sumtec/archiv.../19/94110.aspx

/*
*以下仅是示例代码,仅供参考。
*/

//aUrl就是PUSH消息所包含的URL,注意该URL不包含"http://";
//aPrompt就是UTF-8编码的PUSH提示消息。
void AssembleWapPushMessage(const TDesC8& aUrl, const TDesC8& aPrompt)
{
HBufC8* wapPushMsg = HBufC8::NewLC(1024);

TPtr8 msgPtr = wapPushMsg->Des();
msgPtr.Zero();

//组装WAP PUSH消息
//PUD
msgPtr.Append(0x29);
msgPtr.Append(0x06);
msgPtr.Append(0x06);
msgPtr.Append(0x03);
msgPtr.Append(0xAE);
msgPtr.Append(0x81);
msgPtr.Append(0xEA);
msgPtr.Append(0x8D);
msgPtr.Append(0xCA);

//WAP PUSH的内容字段
msgPtr.Append(0x02);
msgPtr.Append(0x05);
msgPtr.Append(0x6A);
msgPtr.Append(0x00);
msgPtr.Append(0x45);
msgPtr.Append(0xC6);
msgPtr.Append(0x0C);
msgPtr.Append(0x03);

//添加URL
msgPtr.Append(aUrl);
msgPtr.Append(0x00);
msgPtr.Append(0x01);
msgPtr.Append(0x03);

//添加WAP PUSH消息体
msgPtr.Append(aPrompt);
msgPtr.Append(0x00);
msgPtr.Append(0x01);
msgPtr.Append(0x01);

//提交发送请求
SendWapPushSmsL(_L("13800138000"), msgPtr);

CleanupStack::PopAndDestroy(wapPushMsg);
}


TBool SendWapPushSmsL(const TDesC& aAddress, const TDesC8& aMessage)
{
//创建消息
CreateWapPushMessageL(aAddress, aMessage);
// Validate it before sending
if(ValidateCreatedSMS())
{
// Now send
SendSMS2L();
return ETrue;
}
else
{
return EFalse;
}
}

void CreateWapPushMessageL(const TDesC& aAddress, const TDesC8& aMessage)
{
// Set SMS parameters
TMsvEntry indexEntry;
indexEntry.iDate.HomeTime();

CSmsSettings& serviceSettings = iSmsMtm->ServiceSettings();

indexEntry.SetInPreparation(ETrue);
// This is an SMS message
indexEntry.iMtm = KUidMsgTypeSMS;
indexEntry.iType = KUidMsvMessageEntry;
//Gets the ID of the current SMS service.
indexEntry.iServiceId = iSmsMtm->ServiceId();

// Create entry to drafts
iSmsMtm->SwitchCurrentEntryL(KMsvDraftEntryId);

// Creates a new child entry owned by the context synchronously.
iSmsMtm->Entry().CreateL(indexEntry);

// Set the MTM's active context to the new message
iSmsId = indexEntry.Id();
iSmsMtm->SwitchCurrentEntryL(iSmsId);

// Add message body. Body is set twice because index entry keeps a copy
// of some summary information. Index entry and full stored entry
// must be in sync.
// Set the SMS message settings for the message.
CSmsHeader& header = iSmsMtm->SmsHeader();
CSmsMessage &msg = header.Message();
TSmsUserDataSettings smsSettings;
smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
msg.SetUserDataSettingsL(smsSettings);

CSmsPDU &pdu = msg.SmsPDU();
CSmsUserData& userData = pdu.UserData();
userData.SetBodyL(aMessage);

pdu.SetBits7To4(TSmsDataCodingScheme::ESmsDCSTextUncompressed7BitOr8Bit);
pdu.SetClass(TRUE, TSmsDataCodingScheme::ESmsClass1);
pdu.SetPIDType(TSmsProtocolIdentifier::ESmsPIDTelematicInterworking);
pdu.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet8Bit);

TBuf8<16> smsPort;
smsPort.SetLength(4);
smsPort[0] = 0x0B;
smsPort[1] = 0x84;
smsPort[2] = 0xF0;
smsPort[3] = 0x00;
userData.AddInformationElementL(CSmsInformationElement::ESmsIEIApplicationPortAddressing16Bit,smsPort);

serviceSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
serviceSettings.SetDelivery( ESmsDeliveryImmediately ); // to be delivered immediately
serviceSettings.SetDeliveryReport(EFalse);
header.SetSmsSettingsL( serviceSettings );// new settings

//添加收件人
iSmsMtm->AddAddresseeL(aAddress);
indexEntry.iDetails.Set(aAddress);

// Commit changes because index entry is only a local variable
iSmsMtm->Entry().ChangeL(indexEntry);

// Save full message data to the store
iSmsMtm->SaveMessageL();
}

TBool ValidateCreatedSMS()
{
TMsvPartList partsToBeChecked = KMsvMessagePartBody | KMsvMessagePartRecipient |
KMsvMessagePartOriginator | KMsvMessagePartDate;

// ValidateMessage return KErrNone if message is valid.
TMsvPartList failedParts = iSmsMtm->ValidateMessage(partsToBeChecked);

if (failedParts == KMsvMessagePartNone)
{
return ETrue;
}
else
{
return EFalse;
}
}

void SendSMS2L()
{
// Changes the entry on which later actions are performed to the entry with the
// specified TMsvId.
iSmsMtm->SwitchCurrentEntryL(iSmsId);

// Load the created message
iSmsMtm->LoadMessageL();

// Gets the current SMS service settings
CSmsSettings& serviceSettings = iSmsMtm->ServiceSettings();

// Gets the number of service centre addresses stored in this object.
const TInt numSCAddresses = serviceSettings.NumSCAddresses();

// There should always be a service center number
if (numSCAddresses > 0)
{
CSmsNumber* serviceCentreNumber = NULL;

// get the service center number
if ((serviceSettings.DefaultSC() >= 0) && (serviceSettings.DefaultSC() < numSCAddresses))
serviceCentreNumber = &(serviceSettings.SCAddress(serviceSettings.DefaultSC()));
else
serviceCentreNumber = &(serviceSettings.SCAddress(0));

iSmsMtm->SmsHeader().SetServiceCenterAddressL(serviceCentreNumber->Address());
}
else
{
// Leave if there is no service center number
User::Leave(0);
}

iSmsMtm->SaveMessageL();

// Index entry must be Updated
TMsvEntry indexEntry = iSmsMtm->Entry().Entry();
// Set in-preparation flag
indexEntry.SetInPreparation(EFalse);
// Sets the sending state
indexEntry.SetSendingState(KMsvSendStateWaiting);
iSmsMtm->Entry().ChangeL(indexEntry);

// Time to send the message
Cancel(); // prepare iMsvOper for use
iEntrySelection->Reset();
iEntrySelection->AppendL(iSmsId);

TBuf8<1> dummyParam;
// There is also InvokeSyncFunctionL which is synchronous.
iMsvOper = iSmsMtm->InvokeAsyncFunctionL(ESmsMtmCommandScheduleCopy, *iEntrySelection, dummyParam, iStatus);
SetActive();
}
  # 9  
2007-04-02, 07:58
yangsy.mis
Registered User
 
Join Date: Mar 2007
Posts: 9
Re: [请教]如何发wap push短信

哈哈,您所提供的代码确实实现了发送wap push短信的功能
大家用这段代码的时候,记住
include
不然编译会通不过

你可能感兴趣的:(WAP,咨询,JavaScript,制造)