是否可以通过Google API从用户的个人资料中获取信息?如果可能,我应该使用哪个API?
我对这些信息感兴趣:
从用户的个人资料中获取其他信息也很酷.
当我收到这样的远程通知时,我实现了一个打开AlertView的函数:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){
var notifiAlert = UIAlertView()
var NotificationMessage : AnyObject? = userInfo["alert"]
notifiAlert.title = "TITLE"
notifiAlert.message = NotificationMessage as? String
notifiAlert.addButtonWithTitle("OK")
notifiAlert.show()
}
Run Code Online (Sandbox Code Playgroud)
但NotificationMessage总是零.
我的json有效负载如下所示:
{"aps":{"alert":"Testmessage","badge":"1"}}
Run Code Online (Sandbox Code Playgroud)
我正在使用Xcode 6,Swift和我正在为iOS8开发.我现在搜索了几个小时,但没有找到任何有用的信息.通知工作完美..如果我点击它,将打开alertview.我的问题是,我无法从userInfo中获取数据.
我来回让我的网站上的用户改变他们的用户名,这将通过网站显示.一方面,我想给用户灵活性.但另一方面,我不希望他们使用此功能作为一种隐藏方式,如果他们在网站上做了不需要的事情.我知道SO和Twitter可以让你改变你的显示名称.是什么让某人在网站上表现不好,然后更改他们的名字,以便他们可以继续表现不好?
我需要反馈专业人士和骗子.谢谢!
更新: 清理一下.我没有使用用户名作为主要内部帐户ID.每个用户都有一个唯一的号码.我的问题并不是我的系统跟踪用户关于其他用户如何能够互相跟踪的系统.
如果userA知道userB正在做坏事,那么userB将他的名字改为userC.然后userA将不再知道他是谁.
由于NSNotificationCenter.defaultCenter().postNotificationName userinfo只接受符合AnyObject协议的数据的字典,有没有人有任何建议如何发布结构作为NSNotification的一部分?
我最初的想法是将结构包装在一个类中 - 但是那么首先使用结构的意义何在.
我是否遗漏了某些内容,或者这只是将Swift与为Objective C构建的API混为一谈的结果?
这是我所描述的一个示范: -
class wrapper: NSObject {
var aStructToWrap: aStruct
init(theStruct: aStruct) {
aStructToWrap = theStruct
super.init()
}
}
struct aStruct {
var aValue: String
}
let aRealStruct = aStruct(aValue: "egg")
NSNotificationCenter.defaultCenter().postNotificationName("aKey", object: nil, userInfo: ["anotherKey": aRealStruct]) // ERR: Extra argument 'userinfo' in call
let wrappedStruct = wrapper(theStruct: aRealStruct)
NSNotificationCenter.defaultCenter().postNotificationName("aKey", object: nil, userInfo: ["anotherKey": wrappedStruct]) // no error
Run Code Online (Sandbox Code Playgroud) 我想知道如何将一个userInfo对象或任何NSDictionary添加到UIAlertView?
谢谢.
我正在尝试使用NSTimer的userinfo传递UIButton.我已经阅读了NSTimers上有关stackoverflow的每篇文章.我变得非常接近,但却无法到达那里.这篇文章有所帮助
func timeToRun(ButonToEnable:UIButton) {
var tempButton = ButonToEnable
timer = NSTimer.scheduledTimerWithTimeInterval(4, target: self, selector: Selector("setRotateToFalse"), userInfo: ["theButton" :tempButton], repeats: false)
}
Run Code Online (Sandbox Code Playgroud)
计时器运行的功能
func setRotateToFalse() {
println( timer.userInfo )// just see whats happening
rotate = false
let userInfo = timer.userInfo as Dictionary<String, AnyObject>
var tempbutton:UIButton = (userInfo["theButton"] as UIButton)
tempbutton.enabled = true
timer.invalidate()
}
Run Code Online (Sandbox Code Playgroud) 这部分Apple核心数据文档意味着什么?
用户信息词典
托管对象模型中的许多元素 - 实体,属性和关系 - 具有关联的用户信息字典.您可以将任何您想要的信息放入用户信息字典中作为键值对.放入用户信息字典的公共信息包括实体的版本详细信息,以及谓词用于获取的属性的值.
据我所知,默认情况下实体有字典,但我无法在coredata实体或属性上找到userInfo.
我想在UNMutableNotificationContent的userinfo中使用cutom对象,但它不起作用.当我在userinfo中放置自定义对象时,不会触发通知.
使用此代码,会触发通知:
let content = UNMutableNotificationContent()
content.title = "title"
content.body = "body"
content.categoryIdentifier = "alarmNotificationCategory"
content.sound = UNNotificationSound.default()
content.userInfo = ["myKey": "myValue"] as [String : Any]
let request = UNNotificationRequest(identifier: "alarmNotification", content: content, trigger: nil)
UNUserNotificationCenter.current().add(request) { error in
UNUserNotificationCenter.current().delegate = self
if error != nil {
print(error!)
}
}
Run Code Online (Sandbox Code Playgroud)
使用以下内容,不会发出错误,但不会触发通知:
let content = UNMutableNotificationContent()
content.title = "title"
content.body = "body"
content.categoryIdentifier = "alarmNotificationCategory"
content.sound = UNNotificationSound.default()
content.userInfo = ["myKey": TestClass(progress: 2)] as [String : Any]
let request = UNNotificationRequest(identifier: …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Keycloak 的 openId-connect 端点获取有关用户角色的信息。我正在使用/auth/realms/moje/protocol/openid-connect/userinfo
端点来获取有关经过身份验证的用户的信息。我能够获取有关姓名、用户名、电子邮件等的信息,但我无法强制 Keycloak 向我提供有关用户角色的信息。
我已阅读 OpenID 文档,但没有找到任何有关如何获取角色的信息...我认为必须有一种方法可以找出用户角色...也许还有另一个端点...我可以'找不到任何信息...
最后我的问题是:有没有办法使用 OpenID Connect 端点获取有关用户角色的信息?
我曾经通过这个URL获取用户图像
https://plus.google.com/s2/photos/profile/(user_id)?sz=150
但现在我得到的是404错误或没有图像.我知道谷歌已经改变了它的政策和连接方式,并允许其他人获取信息,但我没有做任何事情来达到与上述相同的结果.
注意:我不能在这里使用身份验证,因为我向其他用户显示用户的图像根本没有连接.
或者以其他方式,用户可能不是来自Google登录,但我只需向其他Google用户展示图片.
任何帮助将非常感谢!!!
编辑: 我已通过people.get方法检查
https://www.googleapis.com/plus/v1/people/11595...3592320?key=AIzaSyCkdmtNN1XDg....EpepOIIs
但我得到错误说
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
],
"code": 403,
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:我已经启用此功能,因为我已在我的网站中使用Google+登录,此处我附加了屏幕截图:
userinfo ×10
swift ×4
ios ×3
google-api ×2
attributes ×1
core-data ×1
entities ×1
google-plus ×1
iphone ×1
json ×1
keycloak ×1
nsdictionary ×1
nstimer ×1
oauth ×1
objective-c ×1
struct ×1
uialertview ×1
web ×1