Aamgian 2 Posted March 2, 2020 Hello, I want read Some code from predetermined sender short message for security 2 way my application. have problem to fetch short message. I had test this sample http://www.fmxexpress.com/send-and-fetch-sms-messages-with-delphi-firemonkey-on-android/ But not compatible with Delphi 10.3.3. Any body have reference or sample. Thanks you Share this post Link to post
Dave Nottage 557 Posted March 3, 2020 (edited) Check this link: https://forums.embarcadero.com/thread.jspa?threadID=256233 This is a link to the demo I created: https://forums.embarcadero.com/thread.jspa?messageID=899142 Edit: Just realised you want it for 10.3.3. That old demo might still work, though. If not, I'll help modify it Edit 2: Also now realised you want existing messages. Probably better to use the conversations class: https://developer.android.com/reference/android/provider/Telephony.Sms.Conversations. If the code on FMX Express does not work, please indicate what errors you're having. It may be that you just need to request the READ_SMS permission. Edited March 3, 2020 by Dave Nottage 1 Share this post Link to post
Aamgian 2 Posted March 4, 2020 Thank you Dave, I am done with the Android code of, now I have not found a reference for iOS. the link above that you provide seems to be a problem with the web emb. uses Androidapi.helpers, Androidapi.JNI.GraphicsContentViewText, Androidapi.jni.net, Androidapi.JNI.App, Androidapi.JNI.JavaTypes, function FetchSms(sender:string):string; var cursor: JCursor; uri: Jnet_Uri; address, msgdatesent, body: string; addressidx, msgdatesentidx, bodyidx: integer; fMessage: string; begin uri := StrToJURI('content://sms/inbox'); cursor := TAndroidHelper.Activity.getContentResolver.query(uri, nil, nil,nil,nil); addressidx := cursor.getColumnIndex(StringToJstring('address')); msgdatesentidx := cursor.getColumnIndex(StringToJstring('date_sent')); bodyidx := cursor.getColumnIndex(StringToJstring('body')); cursor.moveToFirst; while (cursor.moveToNext) do begin address := JStringToString(cursor.getString(addressidx)); msgdatesent := JStringToString(cursor.getString(msgdatesentidx)); body := JStringToString(cursor.getString(bodyidx)); if UpperCase(address) = UpperCase(sender) then begin fMessage := msgdatesent+'-'+address+'-'+body; Break end; end; Result := fMessage; end; of course you must be given READ_SMS permission. Share this post Link to post
Dave Nottage 557 Posted March 4, 2020 50 minutes ago, Aamgian said: now I have not found a reference for iOS. That's because you cannot retrieve existing SMS messages on iOS - this is a privacy restriction from Apple. You cannot even intercept new messages. Share this post Link to post