Way to modify Contact's ringtone via ABPerson class iOS? - objective-c

So I've been toying around with the AddressBook framework on iOS and have noticed in the ABPerson class, pretty much every attribute of a contact is listed as a constant (ref: apple documentation). However, one attribute I notice is missing is the ability to make a custom ringtone. Is there any way to modify the ringtone of a contact via the ABPerson class? If not, is there any way at all to modify the custom ringtone using the AddressBook framework? iOS 5.1.1.

Related

How should a Model be implemented in iOS using Objective-C?

EDIT: Although the answers are teaching me things, I still have no
idea how I might "implement" a model. Can anyone give me an example as
to how I would create a simple model class that has a few basic
functions that make calls to NSUserDefaults or JSON web calls and how
I would access this from ANY of my view controllers?
I am just beginning iOS development and have come to the point where my app will require a Model to interact with the overall data flow between controllers, but am unsure as to how they should be implemented properly.
I understand that the View's are in the storyboard, and the Controllers are the classes associated with those views.
What is the proper way to implement a central Model for an app? Do i create a class (ie "MyModel.h/.m") and then import it from all of my view controllers?
I also see people using a UINavigationController->RootViewController as their model, is this viable?
I have googled this question and searched stack overflow for a few hours, but am now resorting to a new question.
EDIT: Although the answers are teaching me things, I still have no
idea how I might "implement" a model. Can anyone give me an example as
to how I would create a simple model class that has a few basic
functions that make calls to NSUserDefaults or JSON web calls and how
I would access this from ANY of my view controllers?
In iOS, a model (MyModel class) is usually a subclass of NSObject or in the case of Core Data (an iOS framework that helps save data to a database locally on the device) NSManagedObject. As with any model object it contains instance variables and getter / setter methods. Most object-oriented languages have a mechanism to provide encapsulation, in iOS a property provides encapsulation and the keyword synthesize automatically generates the getter and setter methods.
View is subclass from *UIView* which provides the capability for handling touch events and drawing.
The UIKit framework contains classes to draw typical interface elements such as tables (lists), buttons, textfields, sliders and more.
Controller is generally a subclass of **UIViewController** that manages a view, it is also responsible for responding to delegation messages and target-action messages.you can have a UITableViewController which is a subclass of UIViewController that manages a UITableView
TabBar and Navigation View Controllers manages an array of view controllers, but Navigation VC manages VC as a “stack” data structure and yes it is a viable usage
please have a look at Design Patterns in ios apple library resource for further reference and here is a apple sample code to understand how to create a network application using the Model-View-Controller design pattern
this tutorial teaches you how to get started with JSON , try integrating FB in your app for understanding JSON as its fun and easy
start coding NSUserDefault in your app for example
// create a standardUserDefaults variable
NSUserDefaults * standardUserDefaults = [NSUserDefaults standardUserDefaults];
// saving an NSString
[standardUserDefaults setObject:#"mystring" forKey:#"string"];
here is a good tutorial i started with..
happy coding :)

Assist me understand ABPeoplePickerNavigationController Class

I am working on iOS Address Book but having some issues, I am referring the iOS programming guide which says
Prompting the User to Choose a Person Record:
The ABPeoplePickerNavigationController class allows users to browse their
list of contacts and select a person and, at your option, one of that
person’s properties. To use a people picker, do the following:
Create and initialize an instance of the class.
Set the delegate, which must adopt the ABPeoplePickerNavigationControllerDelegate protocol.
Optionally, set displayedProperties to the array of properties you want displayed. The relevant constants are defined as integers; wrap
them in an NSNumber object using the numberWithInt: method to get an
object that can be put in an array.
Present the people picker as a modal view controller using the presentModalViewController:animated: method. It is recommended that
you present it using animation.
Point one says Create and initialize an instance of the class, its init methods includes withnibname other property is inputview, can this be used to customize address book gui?
point three is also pointing towards displayedProperties, address book gui can be modified?
Like whatsapp, viber, etc .. I also want to customize the address book
so I can also display status under contacts name, so I can display
custom image as accessories etc etc. Please check the screenshots.
I believe they are not using the build in ABPeoplePickerNavigationController Class.
They fethc all the users from the address book and populate it into a table view.
I don't know of any way to customize the ABPeoplePickerNavigationController Class.

Receive remote control events without audio

Here is some background information, otherwise skip ahead to the question in bold. I am building an app and I would like it to have access to the remote control/lock screen events. The tricky part is that this app does not play audio itself, it controls the audio of another device nearby. The communication between devices is not a problem when the app is in the foreground. As I just found out, an app does not assume control of the remote controls until it has played audio with a playback audio session, and was the last do so. This presents a problem because like I said, the app controls ANOTHER device's audio and has no need to play its own.
My first inclination is to have the app play a silent clip every time it is opened in order to assume control of the remote controls. The fact that I have to do this makes me wonder if I am even going to be allowed to do it by Apple or if there is another way to achieve this without fooling the system with fake audio clips.
QUESTION(S): Will Apple approve an app that plays a silent audio clip in order to assume control of the remote/lock screen controls for the purpose of controlling another device's audio? Is there any way of assuming control of the remote controls without an audio session?
P.S. I would prefer to have this functionality on iOS 4.0 and up.
P.P.S I have seen this similar question and it has gotten me brainstorming but the answer provided is not specific to what I need to know.
NOTE: As of iOS 7.1, you should be using MPRemoteCommandCenter instead of the answer below.
You create various system-provided subclasses of MPRemoteCommand and assign them to properties of the [MPRemoteCommandCenter sharedCommandCenter].
I'm keeping the rest of this around for historical reference, but the following is not guaranteed to work on recent iOS versions. In fact, it just might not.
You definitely do need an audio player but not necessarily an explicit session to take control of the remote control events. (AVAudioSession is implicit to any app that plays audio.) I spent a decent amount of time playing with this to confirm this.
I've seen a lot of confusion on the internet about where to set up the removeControlEventRecievedWithEvent: method and various approaches to the responder chain. I know this method works on iOS 6 and iOS 7. Other methods have not. Don't waste your time handling remote control events in the app delegate (where they used to work) or in a view controller which may go away during the lifecycle of your app.
I made a demo project to show how to do this.
Here's a quick rundown of what has to happen:
You need to create a subclass of UIApplication. When the documentation says UIResponder, it means UIApplication, since your application class is a subclass of UIResponder. In this subclass, you're going to implement the remoteControlReceivedWithEvent: and canBecomeFirstResponder methods. You want to return YES from canBecomeFirstResponder. In the remote control method, you'll probably want to notify your audio player that something's changed.
You need to tell iOS to use your custom class to run the app, instead of the default UIApplication. To do so, open main.m and change this:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([RCAppDel`egate class]));
to look like this:
return UIApplicationMain(argc, argv, NSStringFromClass([RCApplication class]), NSStringFromClass([RCAppDelegate class]));
In my case RCApplication is the name of my custom class. Use the name of your subclass instead. Don't forget to #import the appropriate header.
OPTIONAL: You should configure an audio session. It's not required, but if you don't, audio won't play if the phone is muted. I do this in the demo app's delegate, but do so where appropriate.
Play something. Until you do, the remote controls will ignore your app. I just took an AVPlayer and gave it the URL of a streaming site that I expect to be up. If you find that it fails, put your own URL in there and play with it to your heart's content.
This example has a little bit more code in there to log out remote events, but it's not all that complicated. I just define and pass around some string constants.
I bet that a silent looping MP3 file would help work towards your goal.
Moshe's solution worked great for me! However one issue I noticed is when you paused the audio, the media controls would go away and you won't be able to play it again without going back into the app. If you set the Media Info on the lock screen when you play the audio then this won't happen:
NSDictionary *mediaInfo = #{MPMediaItemPropertyTitle: #"My Title",
MPMediaItemPropertyAlbumTitle: #"My Album Name",
MPMediaItemPropertyPlaybackDuration: [NSNumber numberWithFloat:0.30f]};
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:mediaInfo];

Is Apple deprecating UIPopover?

Since iOS 5.1 was released, the default for showing the Master view controller in split views is a slide in type of thing. In order to present a popover it seems like you have to enable it using a UIPopover controller instead. Does this mean that the popover is going to going out of style?
When it comes to Apple's API's, deprecated means that Apple has specifically stated that something is in the process of going away. It's usually accompanied by advice regarding a new way to accomplish the same thing. So, if Apple ever deprecates UIPopoverController, you'll know it just from reading the documentation.
That said, it's also a good idea to read the release notes for each new version of iOS that comes along. In the iOS 5.1 release notes you'll find a note that explains what you're seeing:
In 5.1 the UISplitViewController class adopts the sliding presentation
style when presenting the left view (previously only seen in Mail).
This style is used when presentation is initiated either by the
existing bar button item provided by the delegate methods or by a
swipe gesture within the right view. No additional API adoption is
required to obtain this behavior, and all existing API, including that
of the UIPopoverController instance provided by the delegate, will
continue to work as before.

Custom string properties in interface builder

Is there a simple way to expose, say, NSString or UIColor properties of a class such that they can be modified in interface builder?
This would be useful e.g. for adding color properties to a custom view (which are then used programmatically) so that they can be manipulated in Interface Builder as is appropriate.
In iOS 8 there are two new properties added, #IBInspectable and #IBDesignable. Here's a full write up.
http://www.weheartswift.com/make-awesome-ui-components-ios-8-using-swift-xcode-6/
This article from Cocoa with Love describes how to do what you want with Interface Builder Plug-ins for Mac development. Unfortunately, it is currently not possible to use IBPlugins with the iPhone SDK (note the Interface Builder Plug-in Programming Guide only appears in Mac OS X documentation, not iOS documentation).
There is no way to add a custom "non-IBOutlet" attribute but I suggest you to add a UILabel to make use of the text attribute of it, and of cause release that when the view is loaded.