Change Page / View in iOS - ios

I have written a function to login to a web service using objective c
- (void) registerAck: (NSNotification *) notification {
NSLog(#"Detected callback for register");
NSString *status = [[notification userInfo] valueForKey:#"result"];
if([status rangeOfString:#"Successful"].location != NSNotFound){
//succesfully registered
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Welcome"
message:#"Thank you for registering. Please login using the created details"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[[NSNotificationCenter defaultCenter] removeObserver:self];
NSLog(#"%#", status);
}
I want to know how I would go about clearing the page and then when the user selects ok on my popup chaining the page to a different one?
The clear page is easy, I would just write a method and then call this before alert[show] but the change of page is where I am stuck - can anyone let me know how I could redirect to a login page programatically?

Related

Delphi - Handle Push Notifications when app is running?

This is how we handle them at XCode:
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSString *message = nil;
id alert = [userInfo objectForKey:#"alert"];
if ([alert isKindOfClass:[NSString class]]) {
message = alert;
} else if ([alert isKindOfClass:[NSDictionary class]]) {
message = [alert objectForKey:#"body"];
}
if (alert) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Title"
message:#"AThe message." delegate:self
cancelButtonTitle:#"button 1"
otherButtonTitles:#"button", nil];
[alertView show];
[alertView release];
}
How do we catch Push Notifications if the iOS application is already running at the same way but using Delphi 10 Seattle?
Note: Sadly I can not test this as I don't have a Mac with me at the moment but this should work
Inside FMX.Platform.iOS you will find the
ApplicationDidReceiveRemoteNotification
Method, so it is implemented in Delphi
procedure TApplicationDelegate.applicationDidReceiveRemoteNotification(
Sender: UIApplication; ANotification: NSDictionary);
begin
PlatformCocoa.ReceivedRemoteNotification(ANotification);
end;
In there you can then get the Notification as a NSDictionary and you can then read the values from that NSDictionary to handle it in a way that you want
You can also refer to Remy's answer on my one question regarding method swizzling telling the App to rather use your version of ApplicationDidReceiveRemoteNotification and not the one in the source
iOS only
Drop a TEMSProvider component on the form
Drop a TPushEvents component on the form
Bind the TPushEvents.Provider to the TEMSProvider
in code somewhere set TPushEvents.Active := True or enable it's AutoActivate property
TPushEvents has an event called PushEvents1PushReceived handle it

How to send action from my app to other app?

I want to send action from my iOS app to other app
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *URLEncodedText = #"...";
NSString *ourPath = [#"...://" stringByAppendingString:URLEncodedText];
NSURL *ourURL = [NSURL URLWithString:ourPath];
if ([ourApplication canOpenURL:ourURL]) {
[ourApplication openURL:ourURL];
}
else {
//Display error
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"..." message:#"..." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
Now, open second app from my app, but I want send action to second app.
Apple added Actions to iOS8 to manage this kind of problems. You can check the docs here.
This way you can offer "services" as Actions to another apps or, if it's your case, consume that actions offered by third party apps.

Local notifications on gps services off

I am using location services on background in my app for fetching user location.
I want to get local notifications from my application when the user switches off the location services in settings page.
Thanks in advance!!!!
Try This :
It's called every time user disable/enable location services in settings
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status;
Why you want to use local notification? Why not UIAlertView?
I would like to suggest you to use UIAlertView as it will inform the user what to do when he/she opens the app. For local notification, you can schedule it. Most likely, the user will not see the notification when the user is on the foreground of the app (when open). And you are not able to know if the app has the right to use location or not if the user never opens the app.
By using didFailWithError delegate method from locationManager, you will be able to know if the user allows your app to get the location or not.
You will have to implement the locationManager delegate method like below:-
- (void)locationManager: (CLLocationManager *)manager didFailWithError: (NSError *)error
{
switch([error code])
{
case kCLErrorNetwork: // general, network-related error
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"" message:#"Network Error" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
}
break;
case kCLErrorDenied:{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"" message:#"YOUR APP NAME doesn't work without Location Services enabled. To turn it on, go to Settings > Privacy > Location Services" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
}
break;
default:
{
}
break;
}
}
If you insist want to implement local notification, replace the above UIAlertView with local notification code.

How to Customize Notification view in ios 6

i m trying to customize notification view, like when we receive default notification its displaying 'DOT' symbol, but i want below image format, here i attached whatever i required notification in my app. pls help me any body knows,
under didReceiveRemote Notification i wrote, like below
mv1 = [[mv alloc]init];
NSLog(#"test%#",userInfo);
[mv1 displayItem:userInfo]; // custom method
imgview.image=[UIImage imageNamed:#"img1.jpeg"];
// NSMutableDictionary *test = [userInfo objectForKey:#"aps"];
// UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Message" message:[test objectForKey:#"alert"] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles: nil];
// [alert show];
//[[NSNotificationCenter defaultCenter] postNotificationName:#"pushNotification" object:nil userInfo:userInfo];
You cant customize notification centre. Because it is related with the OS not a part of your app. Apple wont allow this customization .

Apns-alert customization

I have successfully used APNS in iphone app and still have a problem the alert customization.Below is my question:
1 I can't custom the Alert view,like title and button title.I custom the alert like:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSDictionary *apsDic = [userInfo valueForKey:#"aps"];
NSString *alertStr = [apsDic valueForKey:#"alert"];
NSNumber *badgeNum = [apsDic valueForKey:#"badge"];
NSString *soundStr = [apsDic valueForKey:#"sound"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[arr objectAtIndex:1]
message:msg
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:#"view",nil];
[alert show];
[alert release];
}
In my App, the title of the alert is my app's title;and the button titles are "Close" and "View".
2 when I click the "View", is shows the launch view of my app and then it crashes.Why?
So if the alert is provided by the system which can't be customized, the view action is also under control of system. It seems there's contradiction between 1 and 2.
Any help is appreciated!
thanks
I find: if your app does not start, the apns-alert is provided by the iOS which you can't customize.

Resources