Mac os app signing? - objective-c

I want to use Mountain Lion's new feature Notification Center. In NSUserNotification.h I found lines saying:
// Use of these classes requires your application be signed.
What does that mean? Should I have an Apple developer account and certificate? I Use the classes like this in Console Application.
NSUserNotificationCenter * center = [NSUserNotificationCenter defaultUserNotificationCenter];
NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.title = #"asdasdasdasd";
notification.informativeText = #"text text";
[center deliverNotification:notification];
But nothing really happens. How do I sign the app?

A 2 second google will lead you here: https://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html

Related

iOS Facebook Share with Link, Photo and Description in the same share dialog

After the iOS 11 relase, the SLComposeViewController is depraceted/not allowed sharing. So iOS developers have to use native Facebook and Twitter SDK to share content. And my problems is raising from this point.
I have been developing a new app which is needed facebook sharing with link, photo and description. i have done separately sharing with photo or link with native FBSDK. But i want to ask you, anyone know how can i use photo and link and description in the same Facebook Dialog. Because in my scenario, i have to share discount detail with discounting shop web site(https://emregurses.com/....../shoes), and discount foto(shoes or bag) and the detail text(Hurry up, you can buy until the midnight)
You can see below codes which i use to share separately.
Photo Share
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
shareButton = [[FBSDKShareButton alloc] init];
if (shareImage) {
FBSDKSharePhoto *sharePhoto = [[FBSDKSharePhoto alloc] init];
sharePhoto.caption = facebookTitle;
sharePhoto.image = shareImage;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[sharePhoto];
}
shareButton.shareContent = content;
[shareButton sendActionsForControlEvents: UIControlEventTouchUpInside];
Link Share
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
shareButton = [[FBSDKShareButton alloc] init];
if (facebookUrl) {
content.contentURL = [NSURL URLWithString:facebookUrl];
}else{
content.contentURL = [NSURL URLWithString:#"https://fastpay.com.tr/"];
}
shareButton.shareContent = content;
[shareButton sendActionsForControlEvents: UIControlEventTouchUpInside];
But i want to share all of them in the same FBShare dialog as the before SLComposeViewController. Also imageURL property is deprecated the new SDK.
#property (nonatomic, readonly) NSURL *imageURL
DEPRECATED_MSG_ATTRIBUTE("`imageURL` is deprecated from Graph API 2.9");
You can not share predefined text via facebook share.this is the limitation by facebook you can read more here
Use of the iOS share sheet is subject to Facebook Platform Policy,
including section 2.3 which states that apps may not pre-fill in the
context of the share sheet. This means apps may not pre-fill the share
sheet's initialText field with content that wasn't entered by the user
of the app.

iOS 7 ANCS: Discovering the primary ANCS Service UUID

Under iOS7, is the primary ANCS Service meant to be constantly advertised, or does it need to be enabled in obfuscated settings / implemented using a custom CBPeripheralManager (using the Apple-specified Service and Characteristic UUIDs) for a potential Notification Consumer to successfully discover it and subscribe?
The Apple documentation (both the CoreBluetooth Programming Guide, and the ANCS Specification) are surprisingly bereft of any information on this. They seem to hint at requiring a custom implementation, but this is just conjecture on our part.
Given the primary ANCS Service UUID: 7905F431-B5CE-4E99-A40F-4B1E122D00D0, performing a scan yields no hits. Scanning the entire BLE spectrum, as expected, yields hits for other BLE devices, but not a single ANCS device.
EDIT 1:
Defining a custom CBPeripheralManager and manually adding the Apple-specified ANCS Service with its associated Characteristics fails, with the NSError: Error Domain=CBErrorDomain Code=8 "The specified UUID is not allowed for this operation."
Consequently, it appears that the Service UUID is reserved by Apple (as it should be), and we cannot enable it in this manner.
Any insight is greatly appreciated; we've reached out to Apple about this, and will update when we hear from them.
The code below reproduces the NSError mentioned above:
// define the ANCS Characteristics
CBUUID *notificationSourceUUID = [CBUUID UUIDWithString:#"9FBF120D-6301-42D9-8C58-25E699A21DBD"];
CBMutableCharacteristic *notificationSource = [[CBMutableCharacteristic alloc] initWithType:notificationSourceUUID properties:CBCharacteristicPropertyNotifyEncryptionRequired value:nil permissions:CBAttributePermissionsReadEncryptionRequired];
CBUUID *controlPointUUID = [CBUUID UUIDWithString:#"69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9"];
CBMutableCharacteristic *controlPoint = [[CBMutableCharacteristic alloc] initWithType:controlPointUUID properties:CBCharacteristicPropertyWrite value:nil permissions:CBAttributePermissionsWriteEncryptionRequired];
CBUUID *dataSourceUUID = [CBUUID UUIDWithString:#"22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB"];
CBMutableCharacteristic *dataSource = [[CBMutableCharacteristic alloc] initWithType:dataSourceUUID properties:CBCharacteristicPropertyNotifyEncryptionRequired value:nil permissions:CBAttributePermissionsReadEncryptionRequired];
// define the ANCS Service
CBUUID *ANCSUUID = [CBUUID UUIDWithString:#"7905F431-B5CE-4E99-A40F-4B1E122D00D0"];
CBMutableService *ANCS = [[CBMutableService alloc] initWithType:ANCSUUID primary:YES];
ANCS.characteristics = #[notificationSource, controlPoint, dataSource];
// define the Advertisement data
NSMutableDictionary *advertisementData = [NSMutableDictionary dictionary];
[advertisementData setValue:#"CUSTOM_ANCS" forKey:CBAdvertisementDataLocalNameKey];
[advertisementData setValue:#"7905F431-B5CE-4E99-A40F-4B1E122D00D0" forKey:CBAdvertisementDataServiceUUIDsKey];
// publish the ANCS service
[self.peripheralManager addService:ANCS];
As a belated answer to this question, now that Mavericks is out, here is what we've come up with.
Our initial efforts to implement the ANCS specification between two iOS devices, one as Peripheral one as Central, were unsuccessful. Apple responded to us after some time (hat tip to their evangelists) and told us this was impossible.
With the addition of the CBPeripheralManager class and CBPeripheralManagerDelegate protocol to the CoreBluetooth.framework embedded in the IOBluetooth.framework on OSX Mavericks (deep breath), we can now use the BLE radio on an OSX device to implement and advertise ANCS.
Thus, this snippet belongs to a CBPeripheralManager on OSX:
- (void) advertiseANCS
{
NSLog(#"%s", __FUNCTION__);
// define the ANCS Characteristics
CBUUID *notificationSourceUUID = [CBUUID UUIDWithString:#"9FBF120D-6301-42D9-8C58-25E699A21DBD"];
CBMutableCharacteristic *notificationSource = [[CBMutableCharacteristic alloc] initWithType:notificationSourceUUID properties:CBCharacteristicPropertyNotifyEncryptionRequired value:nil permissions:CBAttributePermissionsReadEncryptionRequired];
CBUUID *controlPointUUID = [CBUUID UUIDWithString:#"69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9"];
CBMutableCharacteristic *controlPoint = [[CBMutableCharacteristic alloc] initWithType:controlPointUUID properties:CBCharacteristicPropertyWrite value:nil permissions:CBAttributePermissionsWriteEncryptionRequired];
CBUUID *dataSourceUUID = [CBUUID UUIDWithString:#"22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB"];
CBMutableCharacteristic *dataSource = [[CBMutableCharacteristic alloc] initWithType:dataSourceUUID properties:CBCharacteristicPropertyNotifyEncryptionRequired value:nil permissions:CBAttributePermissionsReadEncryptionRequired];
// define the ANCS Service
CBUUID *ANCSUUID = [CBUUID UUIDWithString:#"7905F431-B5CE-4E99-A40F-4B1E122D00D0"];
CBMutableService *ANCS = [[CBMutableService alloc] initWithType:ANCSUUID primary:YES];
ANCS.characteristics = #[notificationSource, controlPoint, dataSource];
// define the Advertisement data
NSMutableDictionary *advertisementData = [NSMutableDictionary dictionary];
[advertisementData setValue:#"ANCS" forKey:CBAdvertisementDataLocalNameKey];
[advertisementData setValue:#[ANCSUUID] forKey:CBAdvertisementDataServiceUUIDsKey];
// publish the ANCS service
[self.peripheralManager addService:ANCS];
[self.peripheralManager startAdvertising:advertisementData];
}
Whereas this snippet belongs on a CBCentralManager on an iOS device:
- (void) discoverANCS
{
NSLog(#"%s", __FUNCTION__);
NSMutableArray *services = [NSMutableArray array];
[services addObject:#"7905F431-B5CE-4E99-A40F-4B1E122D00D0"];
NSMutableDictionary *options = [NSMutableDictionary dictionary];
[options setValue:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
[self.centralManager scanForPeripheralsWithServices:services options:options];
}
The iOS device can now see and connect to the OSX radio, which implements the ANCS specification as detailed in the Apple documentation.
<CBCentralManager: 0x14e23280> <CBPeripheral: 0x14d27b40 identifier = 7231B80F-874E-DB5F-2AF9-7F376911E2B7, Name = "ANCS", state = disconnected> {
kCBAdvDataChannel = 39;
kCBAdvDataIsConnectable = 1;
kCBAdvDataLocalName = ANCS;
} -60
Happy hunting
Well the reason is because you are setting the UUID for the advertisement Data Dictionary as a String and not as a CBUUID, also I think that key takes an array of CBUUIDs.
therefore this should make it work:
NSDictionary *advertisementData = #{
CBAdvertisementDataServiceUUIDsKey:#[[CBUUID UUIDWithString:#"7905F431-B5CE-4E99-A40F-4B1E122D00D0"]],
CBAdvertisementDataLocalNameKey:#"ANCS",
};
EDIT: Oh yeah my bad! I forgot to mention that if you are trying to discover this ANCS service from another iOS Device you wont be able to see it, not under iOS 7. Somehow the OS is reserving that service to itself and wont show up on your didDiscoverServices callback even though you might be seeing it on your advertisement data. It will however, work if you have an external device, like a non-iOS device, or a pebble-like device. This is how you expose the ANCS functionality but the rest of the implementation is up to consumer of the service.
According to this blog post:
http://blog.punchthrough.com/post/63658238857/the-apple-notification-center-service-or-wtf-is
You can advertise with 'service solicitation' to pair and access the ANCS without writing any code on the iPhone!
I have not tried it, but will soon.
For anyone currently Googling a similar question: ANCS via CoreBluetooth appears to no longer work in iOS 9. Specifically,
This functionality was removed from OS X and iOS.
Neither platform can be used to consume the ANCS service anymore using CoreBluetooth.
Given by https://forums.developer.apple.com/thread/24336
The ANCS is not advertised on iOS, I used a following way to achieve a long time connection with ANCS:
My peripheral device uses a dummy service, which is advertised. An iOS application is used to discover a device with this service and to create a connection. You can write your own application, or use one of free available (like LightBlue for example).
Once a connection is established, the peripheral device enumerates all services present on connected iOS device. Beside of others, there are those three mentioned in ANCS documentation.
If your register notifications for them, you will get ANCS data.
If you bond devices (iOS and peripheral), ANCS will automatically care for connection (re)establishment any time, if it found bonded device being advertised.
I use ANCS without any code on the iPhone using "pebble-like" prototype hardware.
Using the methods documented above on this question.
The video is for a kind of joke show and meant as a joke as is the concept of "area-wide notifications" :-) and not at all technical. But might be informative somewhat.
http://www.youtube.com/watch?v=O-YWMl7IS-g
I don't make money from my youtube BTW
I have not been successful with iOS--iOS attempts.

iOS5 local notification custom sound xcode iOS iPhone objective-c Xcode

I am trying to set custom local notification sound like this:
UILocalNotification *notification = [UILocalNotification new];
notification.timeZone = [NSTimeZone systemTimeZone];
notification.fireDate = date;
notification.alertAction = #"123";
notification.alertBody = #"123";
//!!!
notification.soundName = #"Glass.aiff";
alarmID=[NSString stringWithFormat:#"%i", arrayAlarms.count];
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:alarmID forKey:#"id"];
notification.userInfo = infoDict;
notification.repeatInterval=NSWeekCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
But I hear only default sound. I am testing app on ios5. Great thanks for help in advance and sorry for my english.
Custom Notification sounds are restricted to less than 30 seconds. If your sound is longer than this iOS will play the default sound instead. Could this be your problem?
For more info see here. https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html
"Custom sounds must be under 30 seconds when played. If a custom sound is over that limit, the default system sound is played instead."
Check your syntax , its wrong. check with this,
notification.soundName = "Glass.aiff";
One can still use UILocalNotificationDefaultSoundName for default local notification sound.
notification.soundName = #"Glass.aiff";
That should work. Make sure the sound(Glass.aiff) is actually in your app’s bundle, and is under 30 seconds.We can't set a custom sound that not present in our app's bundle ie from Document folder etc.

Get mails from iphone settings

there any way to get my personal email accounts created in the iphone settings ??
I am making an application to send mail and would like to select one of the email accounts I have on my iPhone to send and then select the destianatorios of my agenda.
Thanks
I'm not exactly sure what you're trying to do, but iOS offers several ways to display an email composition view controller, as well as methods to access the contacts a user has saved on his /her iDevice.
To display a mail composition view, make a weak link to the MessageUI.framework in your project (a weak link is preferred since the MessageUI.framework is not available on very old iOS versions), then do something like this:
Class mailClass = (NSClassFromString(#"MFMailComposeViewController"));
if (mailClass != nil) {
// MessageUI Library is available. Presenting modal mail composer view.
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:#"This is the subject of the email"];
[mailViewController setMessageBody:#"This is the body of the email." isHTML:NO];
[self presentModalViewController:mailViewController animated:YES];
[mailViewController release];
} else {
// MessageUI Library not available. Opening mail.app using a URL scheme.
// Note that this URL scheme only works on iOS3 and below, and seems to only accept a
// limited number of characters. For this reason, we only attach the URL.
NSString *mailBody = #"This is the body of the email."
NSString *mailSchemeURL = [NSString stringWithFormat:#"mailto:?body=%#", mailBody];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[mailSchemeURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
}
If you want to access contacts on the iDevice, link AddressBook.framework into your project. You can access the values on the device by following the instructions in Apple's programming guide. For example, you can get an array of all contacts like so:
ABAddressBookRef addressBook = ABAddressBookCreate();
NSArray *contacts = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
I expect you can instantiate a mail composition view with a specific contact by using a combination of the above. Hope this helps!

Iphone SDK 4 sms composer

Have anyone tried to use the SDK4's SMS composer?
If anyone's got some reference or source code please put in here
Thanks
If you want to support 3.1 devices, you need to do a few things:
In your target's build settings:
set Base SDK to iPhone Device 4.0
set iPhone OS Deployment Target to iPhone OS 3.x (the lowest OS level you want to support)
In your target's general settings, under Linked Libraries, change the "Type" next to MessageUI.framework to Weak.
Don't import <MessageUI/MFMessageComposeViewController.h> or it will crash on launch on 3.1. Just import <MessageUI/MessageUI.h>
To make sure it doesn't crash on 3.1.x, you need to test for the availability of MFMessageComposeViewController:
Class smsClass = (NSClassFromString(#"MFMessageComposeViewController"));
if (smsClass != nil && [MFMessageComposeViewController canSendText]) {
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
controller.body = text;
controller.recipients = [NSArray arrayWithObjects: nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
[controller release];
}
If you've got the 4.0 SDK already, check MFMessageComposeViewController. The usage is similar to MFMailComposeViewController.