Sending Colored Text Messages in iPhone - iphone

I am working on iPhone App similar to Pimp My text available here:
http://itunes.apple.com/us/app/pimp-my-text-send-color-text/id489972714?mt=8
I am trying to find a way for sending Colored and animated Messages as the app does.
I have tried this by using UIWebview but it seems the paste board is used in the app to send the iMessage but its not working. The paste board copies the message from editor screen of message and paste it to default iMessage controller. But I am not sure how it is done in the app.
Can anyone suggest any way to send the Colored, animated text with effects?

I have fixed this by following code:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.persistent = YES;
NSString *imagefile =app.strimagepath;
///
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:imagefile];
if (fileExists)
{
NSData *data = UIImagePNGRepresentation([UIImage imageWithContentsOfFile:imagefile]);
pasteboard.image = [UIImage imageWithData:data];
}
NSString *phoneToCall = #"sms: 123-456-7890";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];
Here app.strimgPath is the path of image stored in document directory. when the MessageView is opened. Longpress and click on Paste and message will be pasted.
May be the question I asked did not clarified correctly as what I want. But the above was something that solved my purpose.

Related

iPhone App: how to get app icon from app id?

I am looking for a way to get the app icon from the app id. Do you know how to do it? Please share the way. Thanks.
e.g
Instagram, where the id I'm looking for is: id389801252
https://itunes.apple.com/jp/app/instagram/id389801252?mt=8
I want to get this image:
(I composed this answer after 2 minutes of googling... It's just the matter of the correct keyword!)
This is possible using an undocumented documented API of the iTunes Store. It might change in the future, but it doesn't seem to have changed in the near past, so here you are...
NSString *idString = #"id389801252";
NSString *numericIDStr = [idString substringFromIndex:2]; // #"389801252"
NSString *urlStr = [NSString stringWithFormat:#"http://itunes.apple.com/lookup?id=%#", numericIDStr];
NSURL *url = [NSURL URLWithString:urlStr];
NSData *json = [NSData dataWithContentsOfURL:url];
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:json options:0 error:NULL];
NSArray *results = [dict objectForKey:#"results"];
NSDictionary *result = [results objectAtIndex:0];
NSString *imageUrlStr = [result objectForKey:#"artworkUrl100"]; // or 512, or 60
NSURL *artworkURL = [NSURL URLWithString:imageUrlStr];
NSData *imageData = [NSData dataWithContentsOfURL:artworkURL];
UIImage *artworkImage = [UIImage imageWithData:imageData];
Note that this performs two synchronous round-trips using the NSURL API, so you better wrap this in a backgorund thread for maximal user experience. Feed this program an ID string (idString in the code above) and in the end, artworkImage will contain a UIImage with the desired image.
Just for reference, you can use the app's bundle id too:
http://itunes.apple.com/lookup?bundleId=com.burbn.instagram
Not sure if this is at all relevant anymore, but Apple provides an iTunes Link Maker tool. If you use this tool to find your app, you'll also see where it shows an App Icon section. Click embed and grab the img link from there. One thing to note, I did end up playing with the url a bit to find the right size and format I needed (for instance you can get a jpg render instead of png or select an arbitrary size like 128x128)

copy video to uipasteboard

I have successfully able to copy or add the image to pasteboard by using following code:
if (ver_float < 6.0)
{
UIPasteboard *pasteboard;
pasteboard = [UIPasteboard generalPasteboard];
NSString *filePath =pathToImage;
[pasteboard setImage:[UIImage imageWithContentsOfFile:filePath]];
}
else
{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *filePath =pathToImage;
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
[pasteboard setData:videoData forPasteboardType:[UIPasteboardTypeListImage objectAtIndex:0]];
}
NSURL *urlstr = [NSURL URLWithString:#"sms:"];
[[UIApplication sharedApplication] openURL:urlstr];
But the app which I am making is based on both images and videos so that user will be able to send image/video via imessage or messagecomposer. But as I have convert the image into data and added into pasteboard. It is working succesfully and sending through imessage. But I also need to send video via imessage. If anyone has any idea about this please provide me some suggestion or solution.
I would be very thankful for the help.
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:#"http://pathto.mp4"]];
UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
[pasteBoard setData:data forPasteboardType:#"public.mpeg-4"];
#"public.mpeg-4" from http://www.escape.gr/manuals/qdrop/UTI.html
In Swift to copy video to UIPasteboard, assuming you already have a data variable with the movie's binary do :
import UniformTypeIdentifiers
UIPasteboard.general.setData(data ?? Data(),forPasteboardType: UTType.mpeg4Movie.description)
This worked for me. To test, I copied from the app and then pasted to the iPhone notes app.
I have also faced the same issue in sending audio file from SMS.
But sending video and audio from SMS is not possible with current SDK.
You can do this by uploading that video to server and then send that uploaded URL.
How to programmatically send voicemail message on the iPhone?

Display video properly in IMessage

Currently, I am developing an App in which I have to send photo/video via IMessage. Photo
sending code is proper working but when I am sending video via IMessage I am only getting
a icon make in composer no video is display like below:
I am using this code to display video in IMessage for sending:
if (ver_float < 6.0)
{
UIPasteboard *pasteboard;
pasteboard = [UIPasteboard generalPasteboard];
NSString *filePath =pathToVideo;
NSData *datavideo = [NSData dataWithContentsOfFile:filePath ];
[pasteboard setData:datavideo forPasteboardType:[UIPasteboardTypeListImage objectAtIndex:0]];
}
else
{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *filePath =pathToVideo;
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
[pasteboard setData:videoData forPasteboardType:[UIPasteboardTypeListImage objectAtIndex:0]];
}
NSURL *urlstr = [NSURL URLWithString:#"sms:"];
[[UIApplication sharedApplication] openURL:urlstr];
How can I solve this? Thanx in advance.
Sadly, (as simonbs suggested) the UIPasteboard SDK will not be able to help you with this, it does not support video and audio at this moment. Sadly, I might add.
Possible duplicate :
copy video to uipasteboard

MFMessageComposeViewController not displaying camera icon

When I bring up a "New Message" manually I will see a camera icon to the left of the text edit area. When I use the MFMessageComposeViewController it will not display this icon which means you cannot insert images. I know this can be done because the guys that made txtAgif can do it. One subtle difference is the Caps is turned on. This might be a clue as to how they are getting this to work.
I know that MFMessageComposeViewController does not allow you to insert images programmatically and that is why I'm doing the copy to UIPasteboard trick. This part works perfectly.
This same question has been asked here and here the question has not been answered except for the "It can't be done."
This is my first post so I did not have a high enough ranking to contribute to the other question posts.
How are they doing this? Is there a trick to MFMessageComposeViewController or are they using something completely different?
I have fixed this by following code:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.persistent = YES;
NSString *imagefile =app.strimagepath;
///
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:imagefile];
if (fileExists)
{
NSData *data = UIImagePNGRepresentation([UIImage imageWithContentsOfFile:imagefile]);
pasteboard.image = [UIImage imageWithData:data];
}
NSString *phoneToCall = #"sms: 123-456-7890";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];
Here app.strimgPath is the path of image stored in document directory. when the MessageView is opened. Longpress and click on Paste and message will be pasted.
I found the answer! Using UIApplication sharedApplication to launch a blank message works while MFMessageComposeViewController does not. Because I'm using the UIPasteboard I do not need to insert items into the body.
NSString *phoneToCall = #"sms: 123-456-7890";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];
This is a bug in MFMessageComposeViewController because why would they allow images to be inserted into one and not the other. I would insert an image but I'm not allowed to because I do not have enough reputation.

iPhone's Pasteboard not recognizing a URL

I want my app to recognize if the current contents of the Clipboard are a URL, and if it is, I want it to load that URL into a web-view.
I'm using the following statement to do this checking:
if ([pasteboard containsPasteboardTypes: [NSArray arrayWithObject:#"public.url-name"]])
...code to load the URL into the webView
but its not working - the IF statement always returns as FALSE, even when the clipboard's contents are clearly a URL.
Strangely enough though, when I remove this IF statement and just go ahead and load the URL I read from the Clipboard into the webView it works perfectly well. So its definitely just the IF statement that's not working for some reason.
Here's the full code:
// executed on a Button-click:
-(IBAction) showClipBoard {
pasteboard = nil; // resetting the pasteBoard each time
pasteboard = [UIPasteboard generalPasteboard];
NSURL *tempURL = pasteboard.URL;
//Check the pasteboard's value-type:
if ([pasteboard containsPasteboardTypes: [NSArray arrayWithObject:#"public.url-name"]]) {
NSLog(#"URL is: %#", pasteboard.string);
NSURL *url = [NSURL URLWithString: pasteboard.string];
NSURLRequest *req = [NSURLRequest requestWithURL: url];
[webView loadRequest:req];
}
else
NSLog(#"=NOT a valid web-address");
NSString *tempString = [pasteboard valueForPasteboardType:#"public.utf8-plain-text"];
// Show the URL in a text-view box called "clipText":
clipText.text = tempString;
}
Anyone see what's wrong here?
You've probably figured this out by now, but, I ran into the same issue & the following worked for me :-
if ([pasteboard containsPasteboardTypes: [NSArray arrayWithObject:#"public.url"]])
...code to load the URL into the webView