浏览 4503 次
锁定老帖子 主题:PUSH
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
||||||||
---|---|---|---|---|---|---|---|---|
作者 | 正文 | |||||||
发表时间:2007-04-11
哪些手机支持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(); }
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
||||||||
返回顶楼 | ||||||||
发表时间:2007-04-11
发错地方了吧
怎么搞到J2me版面了? |
||||||||
返回顶楼 | ||||||||