Body SMS Twilio in app iOS - ios

I'm making an app for iphone and sending SMS using Twilio for automatic form to send a message when an event determined by the user. I have everything ready but when sending the message only sends the last variable declared, when you have to send the whole body with the three variables. Why can this happen?
NSString *kMessage = (#"%# %# %# %#.", tunombre, _addressOutlet.text, _cityOutlet.text, coordinateLabel.text);
Only send the last variable coordinateLabel.text. Any solutions?

You're not properly concatenating the strings.
Try:
NSString *kMessage = [NSString stringWithFormat:#"%# %# %# %#",tunombre, _addressOutlet.text, _cityOutlet.text, coordinateLabel.text];

Related

iOS: Firebase invite through email not working

I am trying to send the invitation through emails using Firebase. When i select the user and tap on send, i got an alert view saying invitation has been sent successfully. But i am not getting the email to the invitee.
Here is my code for sending the invite.
// Invite friends
id<FIRInviteBuilder> inviteDialog = [FIRInvites inviteDialog];
[inviteDialog setInviteDelegate:self];
FIRInvitesTargetApplication *targetApplication = [[FIRInvitesTargetApplication alloc] init];
targetApplication.androidClientID = #"Android ID";
[inviteDialog setOtherPlatformsTargetApplication:targetApplication];
NSString *message =
[NSString stringWithFormat:#"Try this out!\n -%#",
#"Ankur"];
[inviteDialog setMessage:message];
[inviteDialog setTitle:#"Invites Friends"];
[inviteDialog setDeepLink:#"Deep_Link"];
[inviteDialog setCallToActionText:#"Install!"];
[inviteDialog open];
At the same time, i am getting the invitation if i send it through phone number.
Any help would be appreciated. Thanks!
You need to add your team ID in the firebase console, it is also required that you add an App Store id (it's ok to fake one for testing)
I was having this issue because i have not mentioned the app store id in firebase console. After saving the AppStore ID, the issue got resolved.

Multiple contexts , create only if not exists

I have a view controller that is performing an afnetworking request , and upon the response , I am adding that response to my main MOC , and saving it.
My app is a realtime app , and so , performing certain kinds of requests will send messages from server to client via a long lived web socket. What happens is ,when a client sends a single message , he will receive the same message via socket (and I am going to add apns functionality later on, so he will receive the same functionality via apns as well)
I want the web socket to use a background context, so my UI is taxed less.
Right now I am performing a fetch to see if data already exists. If it does not, then I am adding to the context. This check is being done on the socket side as well as the api side.
My concern is , since they are both going to be checked at such close time intervals to each other, is it possible for them to both say that data doesn't exist, and then both will add to the db, causing an unwanted duplicate?
This is my code for clarification:
if ([Chat fetchById:[jsonBody valueForKey:#"id"] withContext:self.managedObjectContext]==nil) {
NSLog(#"GOT NIL FROM SOCKET");
Chat *chat = [Chat initWithContext:self.managedObjectContext];
chat.id = [jsonBody valueForKey:#"id"];
chat.body = [jsonBody valueForKey:#"body"];
chat.user = [User fetchByID:[jsonBody valueForKey:#"user_id"] inContext:self.managedObjectContext];
NSString *date = [jsonBody valueForKey:#"created_at"];
chat.created_at = [TimeFormatter NSDateFromServerString:date];
chat.group = [Group fetchByID:[jsonBody valueForKey:#"grp_id"] inContext:self.managedObjectContext];
[self.managedObjectContext save:nil];
}

Google app invite SMS not getting sent but email working fine

i have implemented Google App Invite in iOS. Code :
self.inviteDialog = [GINInvite inviteDialog];
[self.inviteDialog setInviteDelegate: self];
NSString* message = [NSString stringWithFormat:#"Message",
[[GIDSignIn sharedInstance] currentUser].profile.name];
[self.inviteDialog setMessage: message];
[self.inviteDialog setTitle: #"App"];
[self.inviteDialog open];
I am able to send the email but SMS are not getting sent.
When i enter a phone number "MFMessageComposeViewController" opens with text :
"Message Link" but then SMS is not getting sent.
Please help
SMS messages are not sent when the message text contains some "more special" characters.
Try to use less number of symbols.
Try to reduce Message length.

Parse iOS - Send push notification at specific time

A part of my app currently lets a user schedule appointments using a UIDatePicker. They press a button and my backend does some work with the date to store the appointment data, then I send a push using the following code:
NSString *objectID = [NSString stringWithFormat:#"user_%lu", (unsigned long)self.salespersonObject.userID];
PFPush *push = [PFPush new];
[push setChannel:[NSString stringWithFormat:#"%#",objectID]];
NSString *message1 = [NSString stringWithFormat:#"%# sent you an appointment request. Visit your profile in the app to confirm", self.currentUser.fullName];
NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
message1, #"alert",
#"Increment", #"badge",#"default",#"sound",
nil];
[push setData: data];
[push sendPushInBackground];
What I'm wondering ... is there any way using the Parse iOS SDK to set a specific time for a push to be delivered? I'd like to also in this method add a push to be sent 1 hour prior to the UIDatePicker date that says something like "Reminder your appointment with x is in 1 hour"
Thanks in advance!
From Parse Doc :
Sending scheduled push notifications is not currently supported by the
iOS or OS X SDKs. Take a look at the REST API, JavaScript SDK or the
Parse.com push console.
The best thing to do IMO is to use Cloud Code, so you can make a trigger (afterSave, afterDelete) or a function that you call from your iOS App.
Since CloudCode use the Javascript SDK you can make something like that:
var tomorrowDate = new Date(...);
var query = new Parse.Query(Parse.Installation);
query.equalTo('user_id', 'user_123');
Parse.Push.send({
where: query,
data: {
alert: "You previously created a reminder for the game today"
},
push_time: tomorrowDate
}, {
success: function() {
// Push was successful
},
error: function(error) {
// Handle error
}
});
Parse Push notification scheduling Guide
You can use parse Background jobs to schedule the push notification.
Here is the link for documentation
There really isn't a whole lot you can do with the iPhone SDK and a closed app.
I would suggest that you assign the push to a channel, sending notifications is often done from the Parse.com push console, the REST API or from Cloud Code, you can also assign background jobs through this medium.
But if you want to stick to objective C as you don't mention any other languages; You can send Local Push Notifications natively but not through the PARSE SDK.

Trying to text from my iOS app fails with wrong number error

So I have a button in my app that people can click which is suppose to open the chat app and allow the user to send a text to the number I specify.
Here is the code:
NSString *phoneNumberStuff = [NSString stringWithFormat:#"tel:%#",self.driverPhoneNumber];
NSString *stringURL = [NSString stringWithFormat:#"sms:%#",phoneNumberStuff];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
What happens is when I click the SMS button it opens the texting app and I see in the TO: field the correct phone number to text a message to. So I type a message and hit send, but I get this response back.
"15558354439876552 Error Invalid Number. Please re-send using a valid 10 digit mobile number or valid short code. text again"
Anyone have a clue?
Your format for the url isn't correct.
You are using
sms:tel:1234567890
When you should use
sms:1234567890

Resources