C
C
chingi32018-02-18 17:49:04
Objective-C
chingi3, 2018-02-18 17:49:04

How to run iOS app from INRequestRideIntent extension?

The task is to create an INRequestRideIntent extension for ordering a taxi via Siri. It was possible to establish contact with Siri, but I just can’t launch the application itself from extention. In this regard, the question is, what needs to be done to make the launch of the application possible? I used the Uber app, they launch the app after specifying the number of passengers.
Thanks in advance!
RideIntentHandler.m

- (void)confirmRequestRide:(INRequestRideIntent *)intent completion:(void (^)(INRequestRideIntentResponse * _Nonnull))completion {
    INRideOption *rideOption = ;
    rideOption.userActivityForBookingInApplication = [[NSUserActivity alloc] initWithActivityType:@"blahblah"];

    INRideStatus *rideStatus = [[INRideStatus alloc] init];
    rideStatus.rideOption = rideOption;
    rideStatus.estimatedPickupDate = [NSDate dateWithTimeIntervalSinceNow:300];
    rideStatus.rideIdentifier = [NSUUID UUID].UUIDString;

    INRequestRideIntentResponse *response = [[INRequestRideIntentResponse alloc] initWithCode:INRequestRideIntentResponseCodeSuccess userActivity:nil];
    response.rideStatus = rideStatus;

    completion(response);
}

AppDelegate.m
- (void)application:(UIApplication *)application handleIntent:(INIntent *)intent completionHandler:(void (^)(INIntentResponse * _Nonnull))completionHandler {  
         [Utils showCommonAlertWithMessage:@"blah"];  
      
         if ([intent isKindOfClass:[INRequestRideIntent class]]) {  
              [Utils showCommonAlertWithMessage:@"blah"];  
         }  
    }  
      
    - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {  
         [Utils showCommonAlertWithMessage:@"blah"];  
      
         if ([userActivity.interaction.intent isKindOfClass:[INRequestRideIntent class]]) {  
              NSLog(@"%@", userActivity.userInfo);  
              [Utils showCommonAlertWithMessage:@"blah"];  
         }  
      
         return YES;  
    }  
      
    - (void)application:(UIApplication *)application didFailToContinueUserActivityWithType:(NSString *)userActivityType error:(NSError *)error {  
         [Utils showCommonAlertWithMessage:@"blah"];  
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question