测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017 年 10 月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 LucaBecchetti 维护。
在开发我的应用Frind期间,我需要管理像 WhatsApp 或 Telegram 一样的应用内通知,但我没有找到我喜欢的内容,因此我创建了这个库。选择 InAppNotify 用于您的下一个项目,我将很高兴为您提供一些小帮助!
★★ 在 GitHub 仓库上 Star 我们,或者 ☕ 给我一杯咖啡 ★★
由 Luca Becchetti 创建
以下是 InAppNotify 中您可以找到的主要功能的亮点
纵向
和 横向
方向你喜欢 InAppNotify
吗?我还在开发其他开源库。
这里可以看看
要使用 CocoaPods 将 InAppNotify 集成到您的 Xcode 项目中,在 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'TargetName' do
use_frameworks!
pod 'InAppNotify'
end
然后,运行以下命令
$ pod install
首先,在项目中导入库
import InAppNotify
显示简单通知的基本代码如下
//If you are in a UIViewController
InAppNotify.Show(Announcement(title: "Hello world! my first example!"), to: self)
这是一个用于显示通知的静态方法,它接受两个参数,第一个是公告对象的实例,第二个是 UIViewController 的子类
此库只能显示“公告”对象的一个实例,您可以向其初始化器传递多个参数
let announce = Announcement(
//Title, the first line
title : "I am titile",
//Subtitle, the second line
subtitle : "I am subititle",
//Image local, show if no urlImage is set
image : UIImage(named: "test"),
//URL of remote image
urlImage : "https://.....",
//Seconds before disappear
duration : 3,
//Interaction type. none or text
interactionType : InteractionType.none,
//Pass data to annoucement
userInfo : ["id" : 10],
//Action callback
action: { (type, string, announcement) in
//You can detect the action by test "type" var
if type == CallbackType.tap{
print("User has been tapped")
}else if type == CallbackType.text{
print("Reply from notification: \(string!)")
}else{
print("Notification has been closed!")
}
}
)
创建对象后,您可以使用以下代码显示它
//If you are in a UIViewController
InAppNotify.Show(announce, to: self)
您可以使用一个动作回调与创建的公告进行交互
//Inside initialization of announcement
action: { (type, string, announcement) in
//You can detect the action by test "type" var
if type == CallbackType.tap{
print("User has been tapped")
}else if type == CallbackType.text{
print("Reply from notification: \(string!)")
}else{
print("Notification has been closed!")
}
}
从回调中,您可以访问触发此方法的公告对象,公告有一个特殊的属性称为“userInfo”(它是一个“Any”类型),您可以在创建对象时设置它,并在这里读取
如果您想在下拉通知时启用一个 textField 交互,请将此参数传递给公告对象
//Inside initialization of announcement
interactionType : InteractionType.text,
这将展示一个文本域,用户可以在此处编写!要修改文本按钮(默认为“发送”)请使用此代码
InAppNotify.sendString = "Send"
若要阅读用户输入,如果您已设置动作回调,请测试类型是否为“文本”,并访问字符串变量
//Inside callback
if type == CallbackType.text{
print("Reply from notification: \(string!)")
}
InAppNotify支持主题,默认有两个主题,可以通过“Themes”类访问
要使用主题,您必须设置库的全局变量,例如
//Set dark theme
InAppNotify.theme = Themes.dark
当然,您可以编程创建自定义主题,以下是一个示例
//Create and use a custom theme
InAppNotify.theme = Theme(
titleFont : UIFont.boldSystemFont(ofSize: 18),
subtitleFont : UIFont.systemFont(ofSize: 13),
backgroundColor : UIColor(red:0.90, green:0.58, blue:0.15, alpha:1.00),
dragIndicatorColor : UIColor(red:0.95, green:0.80, blue:0.19, alpha:1.00),
titleColor : UIColor.white,
subtitleColor : UIColor.white,
shadowColor : UIColor.darkGray.cgColor,
inputTextBackgroundColor : UIColor(red:0.95, green:0.80, blue:0.19, alpha:1.00),
inputTextColor : UIColor.white,
sendButtonHighlightedColor : UIColor.darkGray,
sendButtonNormalColor : UIColor.black,
separatorLineColor : UIColor.black
)
我对创建一个所有使用此库的项目列表感兴趣。请随意在GitHub上打开一个带有您项目名称和链接的Issue;我们将将其添加到本网站上。
InAppNotify由Luca Becchetti拥有和维护
作为开源创作,任何帮助都受欢迎!
该库的代码基于MIT许可证发布;您可以无限制地将其用于商业产品。
唯一的要求是在您的关于/贡献部分添加以下文本的一行
In app notification by InAppNotify - http://www.lucabecchetti.com
Created by Becchetti Luca and licensed under MIT License.
我是一名专业程序员,具备软件设计和开发背景,目前正作为项目经理和iOS高级软件工程师,在一家名为“Frind”的初创公司中提升我的技能。
我在软件设计方面技术精湛(拥有10多年的经验),从小就开始担任网管,并且是一名高级PHP开发者。在过去几年中,我专注于移动应用程序编程,使用Swift进行iOS世界开发,以及使用Java进行Android世界开发。
我是一名经验丰富的移动开发人员和架构师,在团队管理、设计和开发方面有数年经验,所有主要移动平台(iOS、Android,经验3年以上)都有涉猎。
我还在客户端和服务器端以及API/网络设计方面拥有广泛的经验。
我所有的最后作品都托管在AWS Amazon云上,我能够配置网络和Unix服务器。对于我的最后一个工作项目,我配置了apache2、ssl、ejabberd集群模式、负载均衡API服务器等。
我住在意大利阿西西(佩鲁贾地区的一个小镇),如有任何疑问,请联系我