Custom iOS emoji keyboard without Unicode - ios

We are trying to create a custom emoji keyboard in iOS 8. We already created a keyboard with our own icons. These icons have no Unicode characters. But I can't pass my icons with text. Is this possible using iOS 8? Why can't I send my own icons?

Brian is correct. The keyboard extension inserts by textDocumentProxy so you cannot use the images. A workaround would maybe be to use the pasteboard like below. Not ideal I know, but it is my only idea. I had this problem a few months ago and came to this same half solution. Keep in mind you will need to grant the keyboard access in the Info.plist file.
"RequestsOpenAccess" = YES in your Info.plist file. AND you have to toggle "Full Access" with settings.
let imageURL = NSBundle.mainBundle().pathForResource("emojiCustom", ofType: "png")
let data = NSData(contentsOfURL: NSURL(fileURLWithPath: imageURL!)!);
UIPasteboard.generalPasteboard().setData(data!, forPasteboardType: "emojiCustom.png")
Then you will need to prompt the user that the custom emoji is available for pasting. I know it is a hack, and not a pretty one, but other than submitting your emojis to unicode for approval (and that would take a lot of time and it is just a proposal, they don't have to approve for adoption) you are limited to a type of hack. If you want to submit to unicode, I have included their link.
http://unicode.org/emoji/selection.html

A different approach that is now available under iOS 10 is their exposure of the iMessages API. You can use your "main" app to allow the user to build a custom emoji "image", or do it yourself and use the iMessage API to attach it directly to the message.

Related

how to access a sound file stored in another app in swift?

this question is a lot like Share data between two or more iPhone applications except:
I'm looking for a way to do this in an iOS 8+ (or 9+) application using swift
I want to be able to use the sound file contained in the first app so the easter egg I'm making is only available when the user has both apps installed
since this is part of an easter egg, i don't want to use any method that would cause anything extra to be displayed on screen such as a browser redirect or some kind of permission popup
(this basically rules out using the share sheet and custom url's to pass data as described in the post above)
I am using AVAudioPlayer and AVAudioSession in the first app to play the sound if that is at all helpful.
Use App Group
You can share actual NSData through the NSUserDefaults:
if let userDefaults = NSUserDefaults(suiteName: <group>) {
userDefaults.setObject(obj, forKey: key)
}
and retrieve from another app in the same group like so:
if let userDefaults = NSUserDefaults(suiteName: <group>) {
if let obj = userDefaults.objectForKey(key) {
// magic
}
}
It appears that the only limitation for passing data through the user defaults is the device storage capacity, and since NSUserDefaults accepts NSData as a storage format, it makes a prime candidate for sharing tidbits information.
If both apps are yours you can implement a custom url scheme in the second app, and then from the first app ask if it knows how to open an URL with that scheme. If the answer is yes, the app is installed. The function is called canOpenURL. It's an instance method of UIApplication.
I vaguely remember that in iOS 9 and later, Apple added a restriction that you have to register the URLs you are going to ask about in your info.plist, but I don't remember the details. That won't prevent this scheme from working, but it is an extra step you have to take.

Show preview of URL while entering a link in UITextView

I need to show a preview of a URL (like FB and WhatsApp do), while the user is entering a link in a UITextView.
Is there a library on iOS to grab it, or do we have to make our own?
Thanks in advance.
iOS does not provide this functionality by default.
You will have to build your own or use an open source solution.
This project might provide what you need:
https://github.com/itsmeichigo/URLPreview

In custom iOS keyboard detect the app

How to detect in which app my custom keyboard used and show different button?
E.g. in Twitter I would add # to string I post into input field and in Reddit /r/
It is possible through following code. As you'll get bundle identifier of the app where you're using your custom keyboard.
Swift
let hostBundleID = self.parentViewController!.valueForKey("_hostBundleID")
let currentHostBundleID = String(hostBundleID)
print(currentHostBundleID);
From bundle identifier you can find app name easily.
Edit: See above. Things have changed.
This is not possible. An extension runs sandboxed and is only fed information from the API and cannot access anything else. The keyboard can only receive text context changes and activate/deactivate calls. Being able to detect an app lies outside of the extension sandbox and therefore is impossible.

Change Safari URL with App Extension

When the icon of my Safari app extension icon is touched, I want to change the URL without showing a new view. Doing this comes down to two issues:
How can I use an safari app extension without showing a new view? I just want to perform a background action when the extension icon is pressed.
How can I change the current URL in Safari?
Actually, you might be able to change the URL at the finalize function of your ExtensionPreprocessingJS file
// Note that the finalize function is only available in iOS.
finalize: function(arguments) {
// arguments contains the value the extension provides in
[NSExtensionContext completeRequestReturningItems:completion:].
// In this example, the extension provides a color as a returning item.
document.URL = arguments["newUrl"];
}
It seems like what you're describing is a bookmark, and not an app extension. I would highly doubt that app extensions would allow you to interface with Safari and update the URL, this would be wrong in many regards, including privacy and security. In short, not possible (sorry).

Is it possible to add PHG affiliate parameters to these new App Store launch URLs in iOS 7?

To launch app page in App Store app on iOS 7, this URL format is required:
#"itms-apps://itunes.apple.com/app/id%#"
Can you also append the affiliate ID and campaign token to this URL like this?
#"itms-apps://itunes.apple.com/app/id%#&at=%#&ct=%#"
Or does it have to be a plain
#"https://itunes.apple.com/app/%#/id%#?mt=8&uo=4"
type URL like you do in websites? Disadvantage of this URL is it opens Safari and causes redirects.
Try it and see; the link will either open or it won't, and if it does, and if you specify a custom campaign for testing, it will either show up in PHG or it won't. Let us know what happens, as I'm curious myself.
Oh, and if it doesn't, please file a bug, as that seems like a useful feature, and it should be trivial for Apple to add it if they haven't already.

Resources