简体   繁体   English

如果用户在目标c中允许推送通知,如何显示警报以感谢您

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

相关问题 如何检测用户是否在Apple的推送通知确认提醒中点击“不允许” - How to detect if user tap on “Don't Allow” on Apple's push notification confirmation alert iOS:如何通过推送通知显示警报并不断播放声音 - iOS: How to show an alert and play sound endlessly through push notification 目标C:是否可能在特定情况下不显示iOS推送通知 - Objective C: Is it possible not to show iOS Push Notifications in specific conditions 在iOS上动态显示推送通知警报 - show alert of push notification dynamically on ios 如何实现iOS 10的推送通知[目标C]? - How to implement push notification for iOS 10[Objective C]? 用户快速点击Firebase通知后如何显示警报? - How to show alert after user tap firebase notification in swift? 如果警报经过验证,如何显示新的视图控制器? (目标c) - How to show a new view controller if the alert is validated? (objective c) 收到推送通知时,应用程序可以决定基于用户词典显示警报吗? - can app decide to show alert based on user dictionary when receiving a push notification? iOS推送通知无法播放声音,并且不显示徽章警报[在Objective C中] - iOS push notifications does not play sound and does not show badge alert [in Objective C] 允许用户选择推送通知时间 - Allow user to choose push notification time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM