[英]iPhone:- How to send push notification to specific Phone number
I have used these methods in my app delegate file and I'm able to activate notification service on my iphone but my issue is that, as I wants to send alarm to my friends iphone when ever I want so. 我已经在我的应用程序委托文件中使用了这些方法,并且能够在iPhone上激活通知服务,但是我的问题是,我想在需要的时候向我的朋友iPhone发送警报。 For that, I want to use push notification that automatically update the alarm time and message in his phone.
为此,我想使用推送通知来自动更新他手机中的闹钟时间和消息。
//in did finishlaunching
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken1 {
NSString *str = [NSString
stringWithFormat:@"Device Token=%@",deviceToken1];
NSLog(@"device......%@",str);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(@"device......%@",str);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
}
Instead of a push notification which would require your friend to register their device. 而不是要求您的朋友注册其设备的推送通知。 Then you would need to determine which device ID belongs to your friend.
然后,您需要确定哪个设备ID属于您的朋友。 A simpler solution I would suggest would be to simply use SMS notifications which would allow you to personalize to whichever phone number you wish.
我建议一个更简单的解决方案是仅使用SMS通知,该通知将使您可以个性化为所需的任何电话号码。
-(IBAction) sendInAppSMS:(id) sender
{
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
controller.body = @"Hello! Time to get up!;
controller.recipients = [NSArray arrayWithObjects:@"12345678", @"87654321", nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
}
source: http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/ 来源: http : //blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/
NOTE: It might be more useful to use SMS because if an individual's phone is off they will get the SMS message once the phone is turned on. 注意:使用SMS可能更有用,因为如果关闭了某个人的电话,他们将在打开电话后收到SMS消息。 However if an individual's phone is off and they are sent a push notification it is not guaranteed that they will receive it.
但是,如果某个人的电话已关闭并且向他们发送了推送通知,则不能保证他们会收到它。 If it is required that they receive the messages, then push notifications may not be the best solution.
如果要求他们接收消息,则推送通知可能不是最佳解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.