Custom URL scheme does not work sometimes in iPhone - iphone

I have an application where I have to get a message from server. The server sends the message in an SMS. Since iPhone applications cannot receive SMS programatically I have registered a Custom URL scheme and prefixing my message with the custom URL value say for ex: mymsg://.
This works fine most of the time. Whenever the SMS is received by the phone and I click reply button, it takes me to the reply state and the original message will appear like a link which I can click which takes me to the application. For some reason, sometimes this message is not clickable. That is, when I click on the message it does not launch the application or simply the message is not clickable. Then if i restart the phone, the link is clickable again and i can click on the link which launches my application. Does anyone know what could be the reason?
-chinnadurai

I've encountered this issue before but I'm not sure it's the same one you're having. What I discovered is that whether or not a custom URL scheme is clickable in Messages.app is determined when the message arrives, not when the user sees the URL.
What this means is that if you send the user your custom scheme URL before they've downloaded the app, that link will never be clickable, even if they go on to download the app at a later time. I've verified this behavior on iOS 7.1 only (haven't checked other versions).
For my case, I can't guarantee that the user has already downloaded the app when I send the message, so my solution was to use a standard http:// url that redirects to the custom myapp:// URL on the server with a 302 redirect. Hope this helps!

Related

Send to Messenger Button on Safari does not send webhook event

I have a 'Send to Messenger' button on my app. It use to work just fine earlier. But now it does not work on Safari on Mac & iOS.
It works on Chrome perfectly, but when clicked from Safari, Facebook is not sending event on my Webhook.
Screenshot below: On Safari I also get a specific page after user clicks on authentication " Tap to go back to URL".
Image where users click on send to messenger button
User is asked to Authenticate
Tap to go back to URL screenshot - Likely Culprit
Button Status shown approved, but in reality its not
The error message given to you is stating the issue:
The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
When you use the Send To Messenger plugin there are some requirements for your own domain. See the documentation here. One if these is that you must whitelist your domain. It states:
Use a fully qualified domain name, such as https://www.messenger.com/. IP addresses and localhost are not supported for whitelisting.
You are serving your application using HTTP from http://alpha.lvh.me:3000 but you must serve it using HTTPS. It's also not clear from their requirements if you can use a port number or not but I think you'd be better looking at ngrok or localtunnel for local development.
[Edit] I think it's probably an issue with the content security policy (CSP) on Safari. Some reading about it here.

invite friends function of hackbook for iphone doen't work on my iphone4s

i downloaded hackbook from https://github.com/facebook/facebook-ios-sdk/tree/master/sample/Hackbook (* i am not sure this is the right place to download it), because i wanted to know how to send an invitation to a friend from a iphone native application.
i clicked "send invite", then on the pop-up page, I selected a friend(another facebook account of mine) and pushed "send" button.
"Sent request successfully." is displayed on the bottom of the screen.
but I don't get any request.
who can tell me how to send an invitation, better if there is a sample.
thanks in advance.
Check if your application is in sandbox mode. Users who are not listed as developers/testers will not receive invites to applications that they do not have the permissions to view.
UPDATE:
As the OP has discovered (see comments below) - the problem was to do with not having a Canvas URL set up in the application settings.
Im not 100% sure why this is ( being an iPhone native application ). Reading through the documentation ( once again :S ) revealed no stated requirement of the Canvas URL. My best guess is that the request needs to be able to be redirected somewhere after it is accepted, if you dont specify the canvas URL maybe somehow you invalidate the request.
Did all the requests that did not go out appear once you specified the Canvas URL?

How to relaunch an app like facebook-ios-sdk does?

Question:
I am actively looking in the source code on Github's facebook-ios-sdk project myself but I was wondering if anyone already knows how to relaunch an app that sent an iPhone user to Safari, such that the user can come back after some work has been finished?
Example:
When using facebook to login, the original app is relaunched after the facebook login page has authenticated the user.
Motivation:
I would like to be able to do the same for youtube videos without having to completely lose the user. I don't want to use the standard webview approach because I don't want to provide extra space to first let the video load for the user and then have the user click the play button. I want to skip the play button and its associated click entirely! Instead I want the user to be able to click on just an everyday regular iPhone button and be shown the video with the navigation for coming back to the app via relaunch.
You need your app to register a "custom URL scheme". Then get the callback in the remote web service to return a URL with that scheme. iOS will then launch your application.
More (somewhat old) info available here.
A list of common custom URL schems on iOS can be found here.
Generally, as part of the OAuth login process, you supply a callback URL as one of the paramaters. What this does, is tell the remote server (YouTube), that on successful authentication, redirect the user to the supplied URL. If YouTube supports this (does it support OAuth?) then on successful user login within safari, youtube will tell users safari to redirect to the supplied url. If this url is a "custom URL scheme" it will cause your app to relaunch and you can handle the situation from there.

Launching an iphone app from custom URL in sms

I have a problem with launching my app from an url in an sms.
When I open my Safari and type "myapp://" it opens my application, but somehow the iPhone sms parser can't recognize my url in the body of the message.
I tried:
myapp://something
myapp:something
<myapp://something>
and still the URL in sms message is not clickable.
I have configured the URL identifier and scheme (because it works through safari).
My solution (not a good one) would be to send the user to Safari with a original http:// address and redirect the user to my app-url. This only requires simple HTML-Knowledge (and a webhost).
http://myapp.info/?id=myuniqueidfortheuser
The downside with this is that you must go through Safari to open the app.
This is the only solution I can think of with these restrictions by Apple.
I really hope they can fix this in the future.
Best of luck to you and I hope you'll solve this problem.

Catching an exception when trying to launch a URL service from within Safari on an iPhone

I was wondering if anyone knows - if I have an iPhone app that is registered with a URL service (e.g. alocola://), which means another app can invoke it by calling its URL - is there any way to embed this URL in an HTML page, and catch the exception if the app is not installed on the user's iPhone?
Or in other words / more details:
I would like to write an app that conforms to some URL invocation (like alocola:// is doing), but would like this app to be launched from a web page read by mobile Safari. However, if the app is not installed on the user's iphone, I would like to be able to display a note saying "you must have the alocola app installed on your iPhone, please download it from the app store by clicking here". Is there a way (perhaps using javascript) to have Safari indicate that the URL cannot be invoked, and catch this in order to display an intelligent message?
Thanks :-)
Ariel
No, there's no way to detect this and display such a message. Instead, you should put text on the webpage saying that the using the link requires your app.