GKAchievementNotification 项目使用教程

GKAchievementNotification 项目使用教程

GKAchievementNotificationGame Center styled UI notifications项目地址:https://gitcode.com/gh_mirrors/gk/GKAchievementNotification

1. 项目的目录结构及介绍

GKAchievementNotification 项目的目录结构如下:

GKAchievementNotification/
├── images/
├── GKAchievementHandler.h
├── GKAchievementHandler.m
├── GKAchievementNotification.h
├── GKAchievementNotification.m
├── LICENSE
└── README.md

目录结构介绍

  • images/: 存放项目所需的图片资源。
  • GKAchievementHandler.h: GKAchievementHandler 类的头文件,定义了处理成就通知的方法和属性。
  • GKAchievementHandler.m: GKAchievementHandler 类的实现文件。
  • GKAchievementNotification.h: GKAchievementNotification 类的头文件,定义了成就通知的显示方法和属性。
  • GKAchievementNotification.m: GKAchievementNotification 类的实现文件。
  • LICENSE: 项目的许可证文件,采用 BSD-3-Clause 许可证。
  • README.md: 项目的说明文档,介绍了项目的基本使用方法和注意事项。

2. 项目的启动文件介绍

项目的启动文件是 GKAchievementHandler.hGKAchievementHandler.m。这两个文件定义了 GKAchievementHandler 类,该类负责处理成就通知的显示。

GKAchievementHandler.h

#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>

@interface GKAchievementHandler : NSObject

+ (GKAchievementHandler *)defaultHandler;
- (void)notifyAchievement:(GKAchievementDescription *)achievement;
- (void)notifyAchievementTitle:(NSString *)title andMessage:(NSString *)message;

@end

GKAchievementHandler.m

#import "GKAchievementHandler.h"
#import "GKAchievementNotification.h"

@implementation GKAchievementHandler

+ (GKAchievementHandler *)defaultHandler {
    static GKAchievementHandler *defaultHandler = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        defaultHandler = [[self alloc] init];
    });
    return defaultHandler;
}

- (void)notifyAchievement:(GKAchievementDescription *)achievement {
    GKAchievementNotification *notification = [[GKAchievementNotification alloc] initWithAchievementDescription:achievement];
    [notification setCompletionHandler:^(BOOL completed) {
        // Handle completion
    }];
    [notification show];
}

- (void)notifyAchievementTitle:(NSString *)title andMessage:(NSString *)message {
    GKAchievementNotification *notification = [[GKAchievementNotification alloc] initWithTitle:title andMessage:message];
    [notification setCompletionHandler:^(BOOL completed) {
        // Handle completion
    }];
    [notification show];
}

@end

3. 项目的配置文件介绍

项目的配置文件主要是 LICENSE 文件,该文件定义了项目的许可证。GKAchievementNotification 项目采用 BSD-3-Clause 许可证。

LICENSE

BSD 3-Clause License

Copyright (c) 2023, typeoneerror
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT

GKAchievementNotificationGame Center styled UI notifications项目地址:https://gitcode.com/gh_mirrors/gk/GKAchievementNotification

  • 17
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郭蔷意Ward

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值