简体   繁体   English

iPhone:-如何将推送通知发送到特定的电话号码

[英]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.

相关问题 如何向特定用户发送解析推送通知 - How to send a Parse Push notification to a specific user 无法将推送通知发送到iPhone - Unable to send push notification to iPhone 如何在通知中心上向特定用户发送推送通知? - How to Send Push Notification to a specific user on Notification Hub? 如何将推送通知发送给选定的用户iPhone? - How can I send push notification to selected Users iphone? 提供商可以将电话号码和设备令牌发送到APNs服务器以进行推送通知吗? - Can provider send phone number along with device token to APNs server for push notification ? 如何在 iOS 中使用 Google Firebase 向特定用户发送推送通知? - How to send push notification to a specific user using Google Firebase in iOS? 推送通知:如何使用Pubnub将推送通知发送到特定设备? - Push notification: How can I send push notification to a specific device using Pubnub? 向知道电话号码的特定设备发送推送通知,parse.com - Sending push notification to specific device knowing phone number, parse.com 如何在iphone地址簿中搜索特定的电话号码? - How to search the iphone address book for a specific phone number? 向特定用户发送远程推送通知 - Send remote push notification to specific user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM