Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting Theme from Remote Push Notification #26

Closed
recoilnetworks opened this issue Oct 7, 2016 · 3 comments
Closed

Setting Theme from Remote Push Notification #26

recoilnetworks opened this issue Oct 7, 2016 · 3 comments

Comments

@recoilnetworks
Copy link

I need to set the theme of the message using a string being sent through a remote push notification. Unfortunately, when I am trying to set it I get this error:

Could not cast value of type 'NSTaggedPointerString' (0x102990630) to 'SwiftMessages.Theme'

Any ideas how I can get this to work? Here is my code:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
    let notification = userInfo["aps"] as! [String: AnyObject]

    if (notification["content-available"] as? NSString)?.integerValue == 1 {
        // Silent
    } else {
        // Audible
        if (application.applicationState == UIApplicationState.active) {
            let view = MessageView.viewFromNib(layout: .MessageViewIOS8)
            view.configureTheme(notification["type"] as! Theme)
            view.configureDropShadow()
            view.configureContent(title: notification["title"] as! String, body: notification["alert"] as! String)
            SwiftMessages.show(view: view)
        } else {

        }
    }
}
@nstefan
Copy link

nstefan commented Oct 7, 2016

This is more a stackoverflow type of question IMHO.
You need to convert the value of notification["type"] (apparently a String) to a Theme.
A solution could be to have a function like: func themeFrom(_ type: String) -> Theme

@wtmoose wtmoose closed this as completed Oct 8, 2016
@recoilnetworks
Copy link
Author

recoilnetworks commented Oct 10, 2016

How is this more of a StackOverflow question? This involves your plugin specifically. Man, whomever is replying to questions about this plugin is rude.

@wtmoose
Copy link
Member

wtmoose commented Oct 10, 2016

Your question can be boiled down to a general question "how do I convert a string into an enum in Swift?" Questions like this are typically asked on StackOverflow and the person who suggested as much (who isn't affiliated with SwiftMessages at all) was as polite as one could expect. Also, in your other post, I gave you my SO handle so that I could help you directly on that forum. Whether or not you agree with posting to SO, it seems like a small ask in return for someone else's time and expertise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants