if ([address rangeOfString:@"@"].location != NSNotFound) formattedAddress =
[@"mailto:" stringByAppendingString:address];
else formattedAddress = [@"tel:" stringByAppendingString:address];
NSDictionary *status = [[IDSIDQueryController sharedInstance]
_currentIDStatusForDestinations:@[formattedAddress] service:@"com.apple.madrid"
listenerID:@"__kIMChatServiceForSendingIDSQueryControllerListenerID"];
return [status[formattedAddress] intValue];
}
%new
- (void)sendMadridMessageToAddress:(NSString )address withText:(NSString )text
{
IMServiceImpl service = [IMServiceImpl iMessageService];
IMAccount account = [[IMAccountController sharedInstance]
__ck_defaultAccountForService:service];
IMHandle handle = [account imHandleWithID:address alreadyCanonical:NO];
IMChat chat = [[IMChatRegistry sharedInstance] chatForIMHandle:handle];
NSAttributedString attributedString = [[NSAttributedString alloc]
initWithString:text];
IMMessage message = [IMMessage instantMessageWithText:attributedString
flags:1048581];
[chat sendMessage:message];
[attributedString release];
}
%end
10.5.4 Edit Makefile and control files
The finalized Makefile looks like this:
export THEOS_DEVICE_IP = iOSIP
export ARCHS = armv7 arm64
export TARGET = iphone:clang:latest:8.0
include theos/makefiles/common.mk
TWEAK_NAME = iOSREMadridMessenger
iOSREMadridMessenger_FILES = Tweak.xm
iOSREMadridMessenger_PRIVATE_FRAMEWORKS = IDS ChatKit IMCore
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall - 9 MobileSMS"
The finalized control looks like this:
Package: com.iosre.iosremadridmessenger
Name: iOSREMadridMessenger
Depends: mobilesubstrate, firmware (>= 8.0)
Version: 1.0
Architecture: iphoneos-arm
Description: Detect and send iMessage example
Maintainer: snakeninny
Author: snakeninny
Section: Tweaks
Homepage: http://bbs.iosre.com