添加wallet

wallet的前身為passbook,2015年WWDC大會蘋果正式改名wallet,passbook是蘋果2012年iOS6開放出來的新功能.可以幫助用戶管理五種類型(Boarding passes(登機(jī)牌),Coupons(優(yōu)惠券),Store cards(購物卡),Event tickets(入場券),Generic(通用卡))的票據(jù)

在iOS中一個(gè)Pass其實(shí)就是一個(gè).pkpass文件,事實(shí)上它是一個(gè)Zip壓縮包,只是這個(gè)壓縮包要按照一定的目錄結(jié)構(gòu)來設(shè)計(jì)
如何創(chuàng)建一個(gè)Pass可以參考Apple的文檔
https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/PassKit_PG/YourFirst.html#//apple_ref/doc/uid/TP40012195-CH2-SW1

-(void)addPassbookView:(NSData *)date{
    NSError *error = nil;
    BOOL passEnbale = [PKPassLibrary isPassLibraryAvailable];//檢查pass是否可用
    if (![PKPassLibrary isPassLibraryAvailable]) {//
        dispatch_async(dispatch_get_main_queue(), ^{
            //[[WaitDialogFullS sharedWaitDialog] endLoading];
            [[[UIAlertView alloc] initWithTitle:@"Error"
                                        message:@"PassKit not available"
                                       delegate:nil
                              cancelButtonTitle:GDLocalizedString(@"jpyd_ok")
                              otherButtonTitles: nil] show];
        });
        return;
    }
    
    if (passEnbale) {
        PKPass *onePass = [[PKPass alloc] initWithData:date error:&error];
        if (error) {
            dispatch_async(dispatch_get_main_queue(), ^{
               // [[WaitDialogFullS sharedWaitDialog] endLoading];
                ZNLog(@"!!!!!ERROR:%@",[error description]);
                
                UIAlertView *alert = [[UIAlertView alloc]initWithTitle:GDLocalizedString(@"jpyd_Friendlyreminder") message:GDLocalizedString(@"sy_onePass") delegate:nil cancelButtonTitle:GDLocalizedString(@"jpyd_ok") otherButtonTitles:nil, nil];
                [alert show];
                [alert release];
            });
            return ;
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            PKAddPassesViewController *passAddViewController = [[[PKAddPassesViewController alloc] initWithPass:onePass]autorelease];
            passAddViewController.delegate = self;
            ChinaEastViewController *app = [ChinaEastViewController sharedBankcommViewController];
            //Application tried to present a nil modal view controller on target .修改聽云,李良
            if (passAddViewController) {
                [app presentViewController:passAddViewController animated:YES completion:^{
                   // [[WaitDialogFullS sharedWaitDialog] endLoading];
                }];
            }
            
        });
    }
    
}

個(gè)人博客地址:https://youyou0909.github.io

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容