[英]How it is possible to show a alert for thank you if user allow push notification in objective c
the problem is that the alert for allow or not allow for push notification comes from server then how can I recognise the buttonAtIndex delegate method of alertview. 问题是允许或不允许推送通知的警报来自服务器,然后如何识别alertview的buttonAtIndex委托方法。 what is the best solution for this.. and the another issue is how it is possible to show the alertview of push notification in every 5 min if the user not allow for the push notification.
最好的解决方案是什么。.另一个问题是,如果用户不允许推送通知,则如何每5分钟显示一次推送通知的alertview。
i am not clear about ur first issue. 我不清楚您的第一个问题。 but In second case, you can add local notification for alert view when user not allowing push notification.
但是在第二种情况下,您可以在用户不允许推送通知时为警报视图添加本地通知。 that will get called after specific time as you will mention.
正如您将提到的,它将在特定时间后被调用。
Question-1 问题1
Ans : if user press the Allow
, the following delegate method is call. 回答:如果用户按下
Allow
,则调用以下委托方法。
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
NSLog(@"device token is: %@",deviceToken);
// In here add your Alertview for Thank you
}
if user press Not Allow
the following delegate method is called 如果用户按
Not Allow
,则调用以下委托方法
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
// in here add your 5 minutes method call
}
Question-2 问题2
payload receving method is 有效载荷接收方法是
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^) (UIBackgroundFetchResult))completionHandler {
NSLog(@"Notification received: %@", userInfo);
completionHandler(UIBackgroundFetchResultNewData);
}
call method in 5 minutes 5分钟内调用方法
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
// in here add your 5 minutes method call
[NSTimer scheduledTimerWithTimeInterval:5*60 target:self selector:@selector(showAlertforenableAction:) userInfo:nil repeats:NO];
}
- (void) showAlert:(NSTimer *) timer {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"yourtitle!"
message:@"yourmessage!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.