The text “Setup Pay” is displayed as IN_APP_PAYMENT_BUTTON_SETUP Pay

I have localization in my project, when I add the Apple payment button, it displays IN_APP_PAYMENT_BUTTON_SETUP instead of “Setup Pay”.

Oddly, the same code displays the correct Apple payment button when adding to another sample project.

 if ([PKPaymentAuthorizationViewController canMakePayments]) { if ([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkVisa, PKPaymentNetworkMasterCard, PKPaymentNetworkAmex]]) { //Standard code } else{ UIButton *btnApplePay = [PKPaymentButton buttonWithType:PKPaymentButtonTypeSetUp style:PKPaymentButtonStyleWhiteOutline]; [btnApplePay setFrame:CGRectMake(10, 10, 294, 50)]; [self.view addSubview:btnApplePay]; } } 

Also, if the PKPaymentButton is less than 128 pixels wide, then PKPaymentButton displays the text "Pay".

+5
source share
1 answer

Finally, I found the cause of this problem.

As I mentioned in my comments, I managed to find the root cause of this problem, which was localization.

I tried to reproduce the same code and environment in a demo application, but could not reproduce the same behavior. Finally, I was able to indicate the exact cause of viz BundleLocalization , which I used in my application, since I need to change languages ​​inside the application on the fly.

When I dug deep inside the BundleLocalization class, I was able to figure out that there is a category called NSBundle+Localization that has a method:

-(NSString*) customLocaLizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName

This seems to ruin the localizationBundle . So, I have to find a workaround for this in order to continue using localization in my application.

+2
source

Source: https://habr.com/ru/post/1269849/


All Articles