小编Sum*_*wal的帖子

如何在swift 2.3中使用#undef指令

我想NSLocalizedString在swift 2.3中取消定义或覆盖,我搜索了很多关于它的内容,最后我在Objective C中找到了一种方法,如下所示.

#undef NSLocalizedString
#define NSLocalizedString(key,_comment) your_function_name
Run Code Online (Sandbox Code Playgroud)

我想在swift中实现这个功能.我只知道Objective C中的NSLocalizedString一个宏.NSBundle.h所以我们可以重新定义它.但是对于swift我们无法实现这一点.我只想重新定义或覆盖swift的NSLocalizedString函数.请帮我解决这个问题.任何帮助都会不胜感激.

localization nslocalizedstring preprocessor-directive swift xcode8.1

5
推荐指数
1
解决办法
292
查看次数

在getDeliveredNotifications(completionHandler :)方法中读取Push Notification有效内容详细信息

这是我的推送通知负载.

{
    "userId":"QA-207-222820",
    "title":"Push new Notification",
    "message":"New Notification",
    "deviceId":"70",
    "deviceName":"R70",
    "notificationType":"1"
}
Run Code Online (Sandbox Code Playgroud)

无法getDeliveredNotifications在ios10中的方法内的通知对象中读取上面的有效负载键和值.

这是getDeliveredNotifications方法内部的通知对象详细信息.

<UNNotification: 0x1742389a0; date: 2017-12-13 09:34:59 +0000,

 request: <UNNotificationRequest: 0x1742389c0; identifier: 067437A1-E8F3-4805-B6D9-
A57BE48E9554, 

content: <UNNotificationContent: 0x17410ba30; title: (null), 
subtitle: (null), body: New Notification 
, categoryIdentifier: , launchImageName: , peopleIdentifiers: (
), threadIdentifier: , attachments: (
), badge: (null), 

sound: <UNNotificationSound: 0x1740b75e0>, 
hasDefaultAction: YES, defaultActionTitle: (null), shouldAddToNotificationsList: YES,
shouldAlwaysAlertWhileAppIsForeground: NO, shouldLockDevice: NO, shouldPauseMedia: NO, 
isSnoozeable: NO, fromSnooze: NO, darwinNotificationName: (null), darwinSnoozedNotificationName: (null), 

trigger: <UNPushNotificationTrigger: …
Run Code Online (Sandbox Code Playgroud)

notifications apple-push-notifications swift ios10

3
推荐指数
1
解决办法
1377
查看次数