Re: Zxing sms body

48 views
Skip to first unread message

Sean Owen

unread,
Jun 15, 2012, 3:50:44 PM6/15/12
to zx...@googlegroups.com
You sure this isn't just the app's behavior in question?
Or, given the snippet, are you suggesting perhaps it's compiled to not include the body?
What have you found in debugging?

sacha1996

unread,
Jun 15, 2012, 4:01:28 PM6/15/12
to zx...@googlegroups.com
Hi Sean,

I'm new to developing. I'm just trying to learn from a source code downloaded from Github.

This is also a code for the SMS. Maybe here is something wrong:
else if([[result substringToIndex:4] caseInsensitiveCompare:@"sms:"] == NSOrderedSame || [[result substringToIndex:4] caseInsensitiveCompare:@"mms:"] == NSOrderedSame || [[result substringToIndex:6] caseInsensitiveCompare:@"smsto:"] == NSOrderedSame || [[result substringToIndex:6] caseInsensitiveCompare:@"mmsto:"] == NSOrderedSame) {
           
[history setType: @"SMS"];
           
NSString *smsFormat = result;
            smsFormat
= [@"sms:" stringByAppendingString:[[smsFormat componentsSeparatedByString:@":"] objectAtIndex:1]];
           
// Strip subject content as the
           
[history setResult:smsFormat];
       
}


Steven Parkes

unread,
Jun 15, 2012, 6:50:23 PM6/15/12
to sacha1996, zx...@googlegroups.com
As documented, iOS devices will not use a body parameter in a url with an sms scheme. All it will use is the number.

It's possible for an app to use MFMessageComposeViewController to create an SMS with a body. The zxing iOS code does not do this. It creates a URL with an sms scheme and a body and (I presume) asks the OS to open it, which will throw away the body. You'd need an app that interprets the URL itself and sets the body or if you want to use Barcodes, it needs to be updated to do that.

On Jun 15, 2012, at 12:37 PM, sacha1996 wrote:

> Hi,
>
> I discovered a problem with the (message) body of the sms action.
> I made a QR-Code with number:1234 and body: hello. So this is encoded as smsto:1234:hello in a QR-Code , but when scanning it with Zxing only the number 1234 comes in the SMS app of the iPhone, but the body is empty.
> Do you know why or what's wrong in the code? Is there are way to get the body too?
>
> Code in SMSAction.m:
> #ifdef SMS_URL_INCLUDE_BODY
> #undef SMS_URL_INCLUDE_BODY
> #endif
>
> @implementation SMSAction
>
> @synthesize body;
>
> + (NSURL *)urlForNumber:(NSString *)number withBody:(NSString *)body {
> NSString *urlString =
>
> #ifdef SMS_URL_INCLUDE_BODY
> (body && [body length]) ?
> [NSString stringWithFormat:@"sms:%@?body=%@", number, [body stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] :
>
> #endif
> [NSString stringWithFormat:@"sms:%@", number];
> return [NSURL URLWithString:urlString];
>
> }
>
> Please help
>
> Thanks!

sacha1996

unread,
Jun 16, 2012, 11:05:37 AM6/16/12
to zx...@googlegroups.com, sacha1996
Hi Steven, thanks for your reply.

I'm trying to use the MFMessageComposeCiewController, but I get an error on every thing I do.
Do you maybe know what's the right way to replace the current Zxing sms action code (that doesn't displays the sms body) with the code here under?

MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
   
if([MFMessageComposeViewController canSendText])
   
{
        controller
.body = body;
        controller
.recipients = [NSArray arrayWithObjects:numbers, nil];
        controller
.messageComposeDelegate = self;
       
[self presentModalViewController:controller animated:YES];
   
}

Steven Parkes

unread,
Jun 16, 2012, 12:10:45 PM6/16/12
to sacha1996, zx...@googlegroups.com
The code looks okay on the face of it and you don't say what error you're getting ...

This really isn't a zxing thing, so you might want to post to StackOverflow or the apple developer forums to get help.
Message has been deleted
Message has been deleted

sacha1996

unread,
Jun 16, 2012, 2:49:02 PM6/16/12
to zx...@googlegroups.com, sacha1996
Steven really thanks for your help - I really appreciate it!
I'm sorry, I forgot to tell the errors.

This is what I have after trying to replace the code with MFMessageComposeViewController
+ (NSURL *)urlForNumber:(NSString *)number withBody:(NSString *)body {

   
   
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];

   
if([MFMessageComposeViewController canSendText])
   
{
        controller
.body = body;

        controller
.recipients = [NSArray arrayWithObjects:number,nil];
        controller.messageComposeDelegate = self;  ERROR: Incompatible pointer types assigning to 'id<MFMessageComposeViewControllerDelegate>' from 'Class'
   
}
   
} ERROR: Control reaches end of non-void function

Please help.
Thanks!

Romain Pechayre

unread,
Jun 17, 2012, 8:26:56 AM6/17/12
to sacha1996, zx...@googlegroups.com
In this context, self is the class and not the instance because your method is prefixed with a "+". I am not sure a class can implement a protocol via class methods, and anyway I do not recommend this. 

-- 
Romain Pechayre
Sent with Sparrow

Reply all
Reply to author
Forward
0 new messages