Check if number is compatible with iMessage

Hi! I have a shortcut that looks for birthdays in my contacts and sends a message if it finds any. I would like to check if the number is compatible with iMessage. If not, I would like to send a whatsapp message instead. Is there a way to check if a number will receive and imessage before sending the message?

I would also like to know if this is possible, as I would like to send a screenshot of my location to anyone that has iMessage else send a url to the maps app if they do not to negate charges!

Hey dude I was playing around and I worked out something that may help, you can get info from a contact and you can get notes, if you manually put in the notes “iMessage” you can use “if” to send your contact through your selected path. I’m not trying to find a way to identify a contact through messages to change the contact info automatically, this is a short term fix though! If I work out how to iterate through each contacts messages and determine if the message bubble is blue or green, I’ll let you know hahah

Okay I’ve worked it out, and I’ve managed to work around what everyone online was saying was impossible. It’s about %98 accurate for me also. But I think you will need to make sure your display is turned all the way up and try to stop it from dynamically changing as this is what I’ve been pulling my hair out over the last 6 days.

Okay so you will need:

Shortcuts,
Actions- free app that gives more shortcut automations,
Scriptable.

How it works, it starts in shortcuts and finds all of your contacts, puts them into a list and then iterates through them one by one; Scriptable is used because when you call the Messages app through shortcuts, it doesn’t give the coloured name of chat bubble… so when you launch it through scriptable it does. So it runs through Scriptable and back to shortcuts, where it will take a screenshot of your screen; it will then crop out two specific areas of the screen.

The first area is the name; as it’s either blue or green.
The second area is where I was most likely to find a chat bubble, if it was an existing chat.

It then takes these two cropped images, merges them into one, and uses the ‘get dominant colour from image’ tool from the actions add on.

The biggest problem I had was that although I was receiving hex codes in which I could identify blue and green, because iPhones use a dynamic display I could never match them.

So what I did was split all the hex codes into a list and I had a eureka moment. 98% of the hex codes that were green started with ‘#7’ so the shortcut takes the list of hex colours, and then uses a regx to take the first two characters. You’re then left with a list. If that list contains a ‘#7’ it writes in the contacts notes ‘SMS’ if otherwise it marks it as ‘iMessage’

You’re contacts should now be sepeatable by a simple input of ‘Get details from contact - notes/text - iMessage/SMS’ round of applause for me.

Please note I have left a couple of show results in there, if you remove them it moves a lot quicker and you don’t have to press a button twice…

So here you go.

Copy and paste this into scriptable, make sure you name the scriptable file ‘GetContact’. And in the options, turn on get ‘share sheet inputs’. URLs & Text.

args.openInEditor = true;

let cl = console.log;

let qName = args.queryParameters.scriptName;
let pNo = args.queryParameters.text;
cl(qName+"  "+pNo);


function getContact() {


let phoneNo = encodeURIComponent(pNo)
cl
cl(phoneNo)

Safari.open(`iMessage://${phoneNo}`);

console.log(url);    
    
}

getContact() 

You will also need to download the actions app:

And this is the shortcut:

https://www.icloud.com/shortcuts/80627f1752d245cbb16910955a095172

Remember, screen brightness all the way up and try to turn off anything that will make it dynamically change.

Let me know what you think.

L.

2 Likes

This is genius. Thanks a ton! I had lost hope on this one but this is great.
Thank you again!!


It’s have a small problem can u help me plz

Hold on I fix old problem now I need this
!

You need to specify your own sound to play. The original shortcut looks to have had a specific sound file the creator used. Just point it at another sound file you have that you think would work well, or delete that and the play sound step entirely if you do not want any audible confirmation.

You may also want to post your prior solution in case it is of use to someone else who encounters the same issue you did.

1 Like

Can u call me in telegram plz @azazws1

Sorry. I don’t use Telegram and the the forum is here to promote shared and open discussion, not private discussion - that way everyone can contribute and everyone can learn.

You’re aware you’re sending contact information to 3rd party apps who might sell that information?

Do you mean “Actions”? If so you can actually view the code from Github to confirm for yourself that it isn’t sending any data back to the developer.

Legit genius…and game changer. Thanks for making this public mate. I tested this on my end and it seems the “screenshot” feature is buggy because all our iPhones have different sizes and therefore, X and Y coordinates. How were you able to find the specific coordinates you needed when first setting this up?