| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/InstantMessage.framework |
| Availability | Available in Mac OS X v10.4 and later. |
| Companion guide | |
| Declared in | IMService.h |
| Related sample code |
The IMService class provides methods for getting information about an instant message service. Each IMService object represents one service available through iChat. Class methods such as allServices and serviceWithName: return these objects. Each object represents a single instant messaging service, allowing you to access the iChat status of the user, the user's list of buddies, and other information that can be integrated into your application. A variety of status notifications related to the user's status and preferences are posted by the IMService custom notification center.
+ imageNameForStatus:
+ myIdleTime
+ myStatus
+ notificationCenter
– localizedName
– localizedShortName
– name
– status
+ imageURLForStatus: Deprecated in Mac OS X v10.5
– peopleWithScreenName:
– screenNamesForPerson:
– infoForAllScreenNames
– infoForPreferredScreenNames
– infoForScreenName:
Returns an array of the currently available services.
+ (NSArray *)allServices
Returns an NSArray of IMService objects corresponding to the current available services (AIM, Bonjour, and so on.).
IMService.hReturns the name of the image for the specified status of a person.
+ (NSString *)imageNameForStatus:(IMPersonStatus)status
The status of a person. See “IMPersonStatus” for possible values.
The name of an image that reflects the current online status of a person; it is usually a colored bubble or triangle.
IMService.h
Returns the number of seconds that the current user is idle.
+ (NSDate *)myIdleTime
The number of seconds that the current user is idle.
IMService.h
Returns the status of the current user.
+ (IMPersonStatus)myStatus
A code representing the status of the current user. See “IMPersonStatus” for possible values.
This status is global across all services.
IMService.h
Returns the custom notification center for the service.
+ (NSNotificationCenter *)notificationCenter
A custom notification center that manages IMService notifications.
IMService.h
Returns the specified service.
+ (IMService *)serviceWithName:(NSString *)name
A service name as returned by a previous call to the name method. Hard-coding the service names is not recommended.
The service specified by name.
IMService.hReturns information about all buddies for the service.
- (NSArray *)infoForAllScreenNames
The dictionaries returned by infoForScreenName: for all buddies.
If the current user has multiple buddies for the same person (determined by the user's Address Book), this method returns the information for all of the accounts belonging to that person.
IMService.hReturns information about just the preferred accounts for all buddies.
- (NSArray *)infoForPreferredScreenNames
An array of the dictionaries returned by infoForScreenName: for all preferred accounts.
If the current user has multiple buddies for the same person (determined by the user's Address Book), this method returns only the information for the preferred accounts belonging to that person. The preferred account is determined by iChat, using a combination of capabilities (video chat capability, audio chat capability, and so on), status (available, idle, away), and other user attributes.
IMService.hReturns information about a buddy with the specified screen name.
- (NSDictionary *)infoForScreenName:(NSString *)screenName
A screen name for a buddy.
Information about a buddy with the specified screen name. See “Screen Name Properties” for the key-value pairs that appear in this dictionary.
IMService.hReturns the user-visible localized name of the service.
- (NSString *)localizedName
The user-visible localized name of the service, such as "AOL Instant Messenger" or "Bonjour".
IMService.hReturns a short version, if available, of the user-visible localized name of the service.
- (NSString *)localizedShortName
The user-visible short localized name of the service, such as "AOL".
IMService.hReturns the fixed canonical name of the service.
- (NSString *)name
The fixed canonical name of the service. This string is not intended to be visible to the user and therefore is not localized.
IMService.hReturns Address Book entries that match the specified screen name of a buddy.
- (NSArray *)peopleWithScreenName:(NSString *)screenName
The screen name of a buddy.
An array of Address Book entries that match the specified screen name of a buddy. Returns an empty array if there is no match.
IMService.hReturns an array of strings that are valid screen names for the specified person.
- (NSArray *)screenNamesForPerson:(ABPerson *)person
An entry in the Address Book.
An array of valid screen names for the specified person. Returns an empty array if there is no match.
IMService.hReturns the login status of the service.
- (IMServiceStatus)status
The login status of the service. One of the constants described in “IMServiceStatus.”
IMService.hKeys for information about a person logged in to an instant message service—specifically, a buddy that appears in the user’s buddy list:
extern NSString *IMPersonAVBusyKey; extern NSString *IMPersonCapabilitiesKey; extern NSString *IMPersonEmailKey; extern NSString *IMPersonFirstNameKey; extern NSString *IMPersonIdleSinceKey; extern NSString *IMPersonLastNameKey; extern NSString *IMPersonPictureDataKey; extern NSString *IMPersonScreenNameKey; extern NSString *IMPersonServiceNameKey; extern NSString *IMPersonStatusKey; extern NSString *IMPersonStatusMessageKey;
IMPersonAVBusyKeyUsed to obtain a person’s busy status. The value is an NSNumber set to 0 if the person’s audio/video capabilities are available, or 1 if they are busy.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonCapabilitiesKeyUsed to obtain a person’s iChat capabilities. The value is an NSArray of capability properties. See “Person Capability Values” for more information.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonEmailKeyUsed to obtain a person’s email address. The value is an NSString containing the person's email address. This is a key used directly by Bonjour; however, if a person has an Address Book entry associated with a relevant AIM account, this key reflects the first email address of that person.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonFirstNameKeyUsed to obtain a person’s first name. The value is an NSString containing the person's first name. This is a key used directly by Bonjour; however, if a person has an Address Book entry associated with a relevant AIM account, this key reflects the first name of that person.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonIdleSinceKeyUsed to obtain a person’s idle status. The value is an NSDate containing the time, in seconds, since the last user activity. Available if the person’s status is idle.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonLastNameKeyUsed to obtain a person’s last name. The value is an NSString containing the person's last name. This is a key used directly by Bonjour; however, if a person has an Address Book entry associated with a relevant AIM account, this key reflects the last name of that person.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonPictureDataKeyUsed to obtain a person’s image. The value is an NSData containing the image for the person’s icon.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonScreenNameKeyUsed to obtain a person’s screen name. The value is an NSString containing the service-specific identifier for a person. For example, "User123" or "steve@mac.com" for AIM, and "John Doe" for Bonjour.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonServiceNameKeyUsed to obtain a person’s service name. The value is an NSString containing the name of the service this person belongs to.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonStatusKeyUsed to obtain a person’s online status. The value is an NSNumber representing the current online status of the person, if known. See “IMPersonStatus” for more information.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonStatusMessageKeyUsed to obtain a person’s status message. The value is an NSString containing the person’s current status message.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
These keys appear in the dictionary returned by the infoForScreenName: method.
InstantMessage/IMService.hA person’s iChat capabilities accessed using the IMPersonCapabilitiesKey key.
extern NSString *IMCapabilityAudioConference; extern NSString *IMCapabilityDirectIM; extern NSString *IMCapabilityFileSharing; extern NSString *IMCapabilityFileTransfer; extern NSString *IMCapabilityText; extern NSString *IMCapabilityVideoConference;
IMCapabilityAudioConferenceA person has audio chat capability.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMCapabilityDirectIMA person has direct connect capability.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMCapabilityFileSharingA person has file sharing capability.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMCapabilityFileTransferA person has file transfer capability.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMCapabilityTextA person has text capability.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMCapabilityVideoConferenceA person has video chat capability.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
InstantMessage/IMService.hThe states of a service.
enum {
IMServiceStatusLoggedOut,
IMServiceStatusDisconnected,
IMServiceStatusLoggingOut,
IMServiceStatusLoggingIn,
IMServiceStatusLoggedIn
};
typedef NSUInteger IMServiceStatus;
IMServiceStatusLoggedOutA service is currently logged out.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMServiceStatusDisconnectedA service was disconnected, not by the user but by the system or because of an error.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMServiceStatusLoggingOutA service is in the process of logging out.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMServiceStatusLoggingInA service is in the process of logging in.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMServiceStatusLoggedInA service is currently logged in.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
InstantMessage/IMService.hThe state of a person across all services.
enum {
IMPersonStatusUnknown,
IMPersonStatusOffline,
IMPersonStatusIdle,
IMPersonStatusAway,
IMPersonStatusAvailable,
IMPersonStatusNoStatus
};
typedef NSUInteger IMPersonStatus;
IMPersonStatusUnknownThe person’s status is unknown.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonStatusOfflineThe person is currently offline.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonStatusIdleThe person is currently idle.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonStatusAwayThe person is currently away.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonStatusAvailableThe person is currently available.
Available in Mac OS X v10.4 and later.
Declared in IMService.h.
IMPersonStatusNoStatusNo status is available.
Available in Mac OS X v10.5 and later.
Declared in IMService.h.
This is accessed using the IMPersonStatusKey key for a buddy or returned by the myStatus method for the current user.
InstantMessage/IMService.h
Posted by the IMService custom notification center when the local user changes their online status. The notification object is an IMService object. The user information dictionary does not contain keys. The receiver should send myStatus to the notification object to get the new online status.
IMService.h
Posted by the IMService custom notification center when a screen name changes some aspect of its published information. The notification object is an IMService object. The user information dictionary always contains the IMPersonServiceNameKey key and may contain any of the other keys as described in “Screen Name Properties”. If a particular attribute is removed, the value for the relevant key is NSNull.
IMService.h
Posted by the IMService custom notification center when a different buddy (screen name) logs in, logs off, goes away, and so on. The notification object is an IMService object. The user information dictionary always contain the IMPersonScreenNameKey and IMPersonStatusKey keys, and no others.
IMService.h
Posted by the IMService custom notification center when the status of a service changes—the current user logs in, logs off, goes away, and so on. The notification object is an IMService object. The user information dictionary does not contain keys. The receiver should send status to the notification object to get the new service status.
IMService.h
Posted by the IMService custom notification center when the current user changes his or her preferred images for displaying status. The notification object is nil. This notification does not contain a user information dictionary. Use the imageNameForStatus: method to get the new images.
IMService.h
Last updated: 2009-07-17