NEWS_AddNotification crashes

Discussion in '3DS - Homebrew Development and Emulators' started by Woni, Apr 15, 2016.

  1. Woni
    OP

    Woni Member

    Newcomer
    30
    11
    Jan 2, 2016
    France
    Result res = NEWS_AddNotification(u"title",5,u"message",7,NULL,0,false);

    It crashes, please help.

    EDIT: ctrulib code is broken atm with news:s
     
    Last edited by Woni, Apr 15, 2016
  2. Gocario

    Gocario GBAFail'd

    Member
    640
    560
    Sep 5, 2015
    France
    Bourg Palette
    You shall declare an u16 string as:
    Code:
    const u16 title[] = { 0x0074, 0x0065, 0x0073, 0x0074, 0x0000 };
    const u16 message[] = { 0x006D, 0x0065, 0x0073, 0x0073, 0x0061, 0x0067, 0x0065, 0x0000 };
    And use it as:
    Code:
    newsInit();
    
    // ...
    
    res = NEWS_AddNotification(title, titleLength /* 4 */, message, messageLength /* 7 */, NULL, 0, false);
    
    // ...
    
    newsExit();
    
     
  3. Woni
    OP

    Woni Member

    Newcomer
    30
    11
    Jan 2, 2016
    France
    It doesn't work
    Code:
    const u16 title[] = { 0x0074, 0x0065, 0x0073, 0x0074};
        const u16 message[] = { 0x006D, 0x0065, 0x0073, 0x0073, 0x0061, 0x0067, 0x0065};
        u16* dataTitle = title;
        u16* dataMessage = message;
        u32 titleLength = 4;
        u32 messageLength = 7;
        u32 imageSize = 0;
        res = NEWS_AddNotification(dataTitle,titleLength,dataMessage,messageLength,NULL,imageSize,false);
     
    Last edited by Woni, Apr 15, 2016
  4. Slashcash

    Slashcash GBAtemp Fan

    Member
    334
    461
    Oct 15, 2015
    Italy
    You seem a little confused on what a pointer is, an array is and how to use them properly. I suggest you to read some more about the topic before proceding.
     
  5. Woni
    OP

    Woni Member

    Newcomer
    30
    11
    Jan 2, 2016
    France
    This doesn't work
    Code:
    const u16 title[] = { 0x0074, 0x0065, 0x0073, 0x0074,0x0000};
    const u16 message[] = { 0x006D, 0x0065, 0x0073, 0x0073, 0x0061, 0x0067, 0x0065,0x0000};   
    u32 titleLength = 4;
    u32 messageLength = 7;
    u32 imageSize = 0;
    res = NEWS_AddNotification(title,titleLength,message,messageLength,NULL,imageSize,false);
     
  6. UraKn0x

    UraKn0x Official senpai

    Member
    360
    268
    Mar 20, 2014
    France
    Did you PROPERLY initialize the mews module using newsInit(); ?
     
  7. Woni
    OP

    Woni Member

    Newcomer
    30
    11
    Jan 2, 2016
    France
    Code:
    Result res = newsInit();
    if(R_FAILED(res))
        printf("news service failed init\n");
    else
        printf("news service init successful\n");
    Yes
     
  8. Ryuzaki_MrL

    Ryuzaki_MrL Furry Addict

    Member
    744
    719
    Jun 23, 2015
    Brazil
    Code:
    #include <3ds.h>
    
    int main(int argc, char **argv)
    {
        newsInit();
        
        const u16 title[] = { 0x0074, 0x0065, 0x0073, 0x0074, 0x0000 };
        const u16 message[] = { 0x006D, 0x0065, 0x0073, 0x0073, 0x0061, 0x0067, 0x0065, 0x0000 };
        
        Result res = NEWS_AddNotification(title, 4, message, 7, NULL, 0, false);
        
        while ( aptMainLoop() )
        {
            hidScanInput();
            if (res)
                break;
            if (hidKeysDown() & KEY_START)
                break;
        }
       
        newsExit();
       
        return 0;
    }
    
    This works for me when I run as cia.
     
  9. Woni
    OP

    Woni Member

    Newcomer
    30
    11
    Jan 2, 2016
    France
    You have CFW so you can use news:u, it doesn't work when using news:s, it's a ctrulib issue