Exclude Ipod Touch Function from Phone iPhone App

How can I exclude call and sms feature from Ipod Touch but keep its functionality on iPhone. The iPod Touch, of course, does not have a phone or SMS available via an add-on app. Technical support kindly suggested that I take a look at the "sysctlbyname" system call and the "CTL_HW" section from the Apple iPhone reference documentation.        http://developer.apple.com/iphone/library/documentation/System/Conceptual/ManPages_iPhoneOS/man3/sysctlbyname.3.html

They said they needed to check the machine class and machine type to determine if the device supports phone calls. Okay, I looked at him and he is Greek for me. On the other hand, this snippet from your forum:

[Bind(Exclude="ID, Name")]

      

to avoid evaluating my contact book feature in the iPod Touch app? If so, I assume it will be inserted into the RetrieveContactInfoViewController.m file, but in which section. (of course there are also RetrieveContactInfoViewAppDelegate files). How can I exclude phone features from iPod Touch?

+2


source to share


2 answers


An easier and safer way to test these capabilities on iPhone OS 3.0 is to ask if the actual feature is supported, not which device. This can be done easily as both calling and sending text are registered url schemes, so just ask if the url can be opened to call or send text.



-(BOOL)canSendTextMessage;
{
  UIApplication* app = [UIApplication sharedApplication];
  return [app canOpenURL:[NSURL URLWithString:@"sms:12345"]];
}

-(BOOL)canMakePhoneCall;
{
  UIApplication* app = [UIApplication sharedApplication];
  return [app canOpenURL:[NSURL URLWithString:@"tel:12345"]];
}

      

+4


source


If I understand your question correctly, you want to limit the capabilities of your own app based on whether the app works on iPod touch versus iPhone? If this is the case ... (if not, you need to rephrase your question)

Have a look at this page in the documentation .

This is for a class UIDevice

that allows you to access basic information about the device the application is running on. The method linked above is a "figurative" property of UIDevice. This can be very helpful. For example:

if ([[[UIDevice currentDevice] model] rangeOfString:@"iPhone"].location != NSNotFound) {
  NSLog(@"I am running on an iPhone (or in the simulator)");
} else {
  NSLog(@"I am running on an iPod touch");
}

      

It can be tedious to use this in a large number of places. It would be helpful here to create a category in the UIDevice like:



//UIDevice+ModelInfo.h
@interface UIDevice (ModelInfo)
- (BOOL) isiPhone;
@end

//UIDevice+ModelInfo.m
@implementation UIDevice (ModelInfo)

- (BOOL) isiPhone {
  static BOOL isiPhone;
  static BOOL modelTypeInitialized;
  if (modelTypeInitialized == NO) {
    modelTypeInitialized = YES;
    isiPhone = ([[self model] rangeOfString:@"iPhone"] != NSNotFound);
  }
  return isiPhone;
}

@end

      

It even caches the result for you, so it just compares the string. Now you can do:

#import "UIDevice+ModelInfo.h"
if ([[UIDevice currentDevice] isiPhone]) {
  NSLog(@"Do something iPhoney");
} else {
  NSLog(@"I cannot do iPhoney things");
}

      

Merry Christmas.

+1


source







All Articles