0

我开发了一个约会应用程序。当我收到推送通知时,我想打电话给特定的人,但现在它只是在我收到推送通知时打开应用程序。

当我收到该约会的推送通知时,如何编写代码来拨打特定约会的电话?

4

2 回答 2

3

对于推送通知,您必须在 appDelegate 中编写代码,

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",[userInfo valueForKey:@"phno"]]]];
}

对于本地通知,

    -(void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
    {
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",[notification.userInfo valueForKey:@"phno"]]]];
    }
于 2011-01-24T07:55:57.537 回答
2

收到通知后,使用给定的电话号码打开拨号器应用程序。注意:这将首先启动您的应用程序,然后快速切换到拨号器。

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://5555555555"]];
}
于 2011-01-24T08:05:59.720 回答